Skip to content

Commit

Permalink
[#12125] Instructor results page stats tables: differentiate students…
Browse files Browse the repository at this point in the history
… with same team and name (#12249)
  • Loading branch information
undermyumbrella1 authored Apr 7, 2023
1 parent 4dd002f commit 8990935
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ public void verifyGqrViewResponses(FeedbackQuestionAttributes question, List<Fee
for (FeedbackResponseAttributes response : responses) {
String[] expectedResponses = getExpectedGqrDetails(question, response, instructors, students);
String recipientTeam = getTeam(question.getRecipientType(), response.getRecipient(), students);
String recipientName = getName(question.getRecipientType(), response.getRecipient(), instructors, students);
verifyTableRowValues(getResponseRow(questionPanel, recipientTeam, recipientName), expectedResponses);
String recipientNameAndEmail = getNameAndEmail(question.getRecipientType(), response.getRecipient(),
instructors, students);
verifyTableRowValues(getResponseRow(questionPanel, recipientTeam, recipientNameAndEmail),
expectedResponses);
}
}
}
Expand All @@ -267,8 +269,9 @@ public void verifyRqgViewResponses(FeedbackQuestionAttributes question, List<Fee
for (FeedbackResponseAttributes response : responses) {
String[] expectedResponses = getExpectedRqgDetails(question, response, instructors, students);
String giverTeam = getTeam(question.getGiverType(), response.getGiver(), students);
String giverName = getName(question.getGiverType(), response.getGiver(), instructors, students);
verifyTableRowValues(getResponseRow(questionPanel, giverTeam, giverName), expectedResponses);
String giverNameAndEmail = getNameAndEmail(question.getGiverType(), response.getGiver(), instructors,
students);
verifyTableRowValues(getResponseRow(questionPanel, giverTeam, giverNameAndEmail), expectedResponses);
}
}
}
Expand Down Expand Up @@ -454,9 +457,10 @@ public void verifyQnViewComment(FeedbackQuestionAttributes question, FeedbackRes
WebElement questionPanel = getQuestionPanel(question.getQuestionNumber());

String giverTeam = getTeam(question.getGiverType(), response.getGiver(), students);
String giverName = getName(question.getGiverType(), response.getGiver(), instructors, students);
String giverName = getNameAndEmail(question.getGiverType(), response.getGiver(), instructors, students);
String recipientTeam = getTeam(question.getRecipientType(), response.getRecipient(), students);
String recipientName = getName(question.getRecipientType(), response.getRecipient(), instructors, students);
String recipientName = getNameAndEmail(question.getRecipientType(), response.getRecipient(), instructors,
students);
WebElement responseRow = getResponseRow(questionPanel, giverTeam, giverName, recipientTeam, recipientName);

verifyResponseRowComment(responseRow, comment, instructors, students);
Expand All @@ -473,7 +477,8 @@ public void verifyGqrViewComment(FeedbackQuestionAttributes question, FeedbackRe

WebElement questionPanel = getQuestionPanel(giverPanel, question.getQuestionNumber());
String recipientTeam = getTeam(question.getRecipientType(), response.getRecipient(), students);
String recipientName = getName(question.getRecipientType(), response.getRecipient(), instructors, students);
String recipientName = getNameAndEmail(question.getRecipientType(), response.getRecipient(), instructors,
students);
WebElement responseRow = getResponseRow(questionPanel, recipientTeam, recipientName);

verifyResponseRowComment(responseRow, comment, instructors, students);
Expand All @@ -491,8 +496,8 @@ public void verifyRqgViewComment(FeedbackQuestionAttributes question, FeedbackRe

WebElement questionPanel = getQuestionPanel(recipientPanel, question.getQuestionNumber());
String giverTeam = getTeam(question.getGiverType(), response.getGiver(), students);
String giverName = getName(question.getGiverType(), response.getGiver(), instructors, students);
WebElement responseRow = getResponseRow(questionPanel, giverTeam, giverName);
String giverNameAndEmail = getNameAndEmail(question.getGiverType(), response.getGiver(), instructors, students);
WebElement responseRow = getResponseRow(questionPanel, giverTeam, giverNameAndEmail);

verifyResponseRowComment(responseRow, comment, instructors, students);
}
Expand Down Expand Up @@ -539,8 +544,10 @@ private void verifyResponseRowComment(WebElement responseRow, FeedbackResponseCo
click(responseRow.findElement(By.id("btn-add-comment")));
WebElement commentModal = waitForElementPresence(By.className("modal-body"));

String editor = getName(comment.getCommentGiverType(), comment.getLastEditorEmail(), instructors, students);
String commentGiver = getName(comment.getCommentGiverType(), comment.getCommentGiver(), instructors, students);
String editor = getName(comment.getCommentGiverType(),
comment.getLastEditorEmail(), instructors, students);
String commentGiver = getName(comment.getCommentGiverType(), comment.getCommentGiver(),
instructors, students);
verifyCommentDetails(commentModal, commentGiver, editor, comment.getCommentText(), true);
}

Expand All @@ -550,8 +557,10 @@ private void verifyGroupedResponseComment(WebElement groupedResponses, int qnNum
Collection<StudentAttributes> students) {
WebElement questionPanel = getQuestionPanel(groupedResponses, qnNum);

String editor = getName(comment.getCommentGiverType(), comment.getLastEditorEmail(), instructors, students);
String commentGiver = getName(comment.getCommentGiverType(), comment.getCommentGiver(), instructors, students);
String editor = getName(comment.getCommentGiverType(), comment.getLastEditorEmail(),
instructors, students);
String commentGiver = getName(comment.getCommentGiverType(), comment.getCommentGiver(),
instructors, students);
verifyCommentDetails(questionPanel, commentGiver, editor, comment.getCommentText(), false);
}

Expand Down Expand Up @@ -585,7 +594,10 @@ private String[][] getExpectedNoResponseDetails(List<StudentAttributes> noRespon
String[][] expectedDetails = new String[noResponseStudents.size()][2];
for (int i = 0; i < noResponseStudents.size(); i++) {
expectedDetails[i][0] = noResponseStudents.get(i).getTeam();
expectedDetails[i][1] = noResponseStudents.get(i).getName();
expectedDetails[i][1] = String.format("%s (%s)",
noResponseStudents.get(i).getName(),
noResponseStudents.get(i).getEmail()
);
}
return expectedDetails;
}
Expand All @@ -601,13 +613,13 @@ private String[][] getExpectedQnViewDetails(FeedbackQuestionAttributes question,
for (int i = 0; i < responses.size(); i++) {
FeedbackResponseAttributes response = responses.get(i);
expected[i][0] = getTeam(giverType, response.getGiver(), students);
expected[i][1] = getName(giverType, response.getGiver(), instructors, students);
expected[i][1] = getNameAndEmail(giverType, response.getGiver(), instructors, students);
if (recipientType.equals(FeedbackParticipantType.NONE)) {
expected[i][2] = NO_TEAM_LABEL;
expected[i][3] = NO_USER_LABEL;
} else {
expected[i][2] = getTeam(recipientType, response.getRecipient(), students);
expected[i][3] = getName(recipientType, response.getRecipient(), instructors, students);
expected[i][3] = getNameAndEmail(recipientType, response.getRecipient(), instructors, students);
}
if (isMissingResponse(response)) {
expected[i][4] = NO_RESPONSE_LABEL;
Expand All @@ -629,7 +641,7 @@ private String[] getExpectedGqrDetails(FeedbackQuestionAttributes question,
expected[1] = NO_USER_LABEL;
} else {
expected[0] = getTeam(recipientType, response.getRecipient(), students);
expected[1] = getName(recipientType, response.getRecipient(), instructors, students);
expected[1] = getNameAndEmail(recipientType, response.getRecipient(), instructors, students);
}
if (response.getFeedbackSessionName() == null) {
expected[2] = NO_RESPONSE_LABEL;
Expand All @@ -650,7 +662,7 @@ private String[] getExpectedRqgDetails(FeedbackQuestionAttributes question,
expected[1] = NO_USER_LABEL;
} else {
expected[0] = getTeam(giverType, response.getGiver(), students);
expected[1] = getName(giverType, response.getGiver(), instructors, students);
expected[1] = getNameAndEmail(giverType, response.getGiver(), instructors, students);
}
if (response.getFeedbackSessionName() == null) {
expected[2] = NO_RESPONSE_LABEL;
Expand Down Expand Up @@ -694,7 +706,7 @@ private String[][] getMcqPerRecipientStatistics(FeedbackQuestionAttributes quest
for (int i = 0; i < recipients.size(); i++) {
String recipient = recipients.get(i);
expectedStatistics[i][0] = getTeam(question.getRecipientType(), recipient, students);
expectedStatistics[i][1] = getName(question.getRecipientType(), recipient, instructors, students);
expectedStatistics[i][1] = getNameAndEmail(question.getRecipientType(), recipient, instructors, students);
}

return expectedStatistics;
Expand Down Expand Up @@ -958,15 +970,15 @@ private WebElement getResponseRow(WebElement questionPanel, String giverTeam, St
}

// For other views
private WebElement getResponseRow(WebElement questionPanel, String userTeam, String userName) {
private WebElement getResponseRow(WebElement questionPanel, String userTeam, String userNameAndEmail) {
List<WebElement> responseRows = getResponseTable(questionPanel).findElements(By.cssSelector("tbody tr"));
for (WebElement responseRow : responseRows) {
List<WebElement> cells = responseRow.findElements(By.tagName("td"));
if (cells.get(0).getText().equals(userTeam) && cells.get(1).getText().equals(userName)) {
if (cells.get(0).getText().equals(userTeam) && cells.get(1).getText().equals(userNameAndEmail)) {
return responseRow;
}
}
throw new RuntimeException("Response not found for " + userName);
throw new RuntimeException("Response not found for " + userNameAndEmail);
}

private List<WebElement> getAllGroupedResponses(WebElement userPanel) {
Expand Down Expand Up @@ -1112,8 +1124,9 @@ private String getTeam(FeedbackParticipantType type, String participant, Collect
return teamName;
}

private String getName(FeedbackParticipantType type, String participant, Collection<InstructorAttributes> instructors,
Collection<StudentAttributes> students) {
private String getName(FeedbackParticipantType type, String participant,
Collection<InstructorAttributes> instructors,
Collection<StudentAttributes> students) {
String name;
if (type.equals(FeedbackParticipantType.NONE)) {
name = NO_USER_LABEL;
Expand All @@ -1139,4 +1152,33 @@ private String getName(FeedbackParticipantType type, String participant, Collect

return name;
}

private String getNameAndEmail(FeedbackParticipantType type, String participant,
Collection<InstructorAttributes> instructors,
Collection<StudentAttributes> students) {
String name;
if (type.equals(FeedbackParticipantType.NONE)) {
name = NO_USER_LABEL;
} else if (type.equals(FeedbackParticipantType.TEAMS)) {
name = participant;
} else if (type.equals(FeedbackParticipantType.INSTRUCTORS)) {
name = instructors.stream()
.filter(instructor -> instructor.getEmail().equals(participant))
.findFirst()
.map(instructor -> String.format("%s (%s)", instructor.getName(), instructor.getEmail()))
.orElse(null);
} else {
name = students.stream()
.filter(student -> student.getEmail().equals(participant))
.findFirst()
.map(student -> String.format("%s (%s)", student.getName(), student.getEmail()))
.orElse(null);
}

if (name == null) {
throw new RuntimeException("Could not find name for : " + participant);
}

return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@
<tr *ngFor="let response of responsesToShow" [class.color-neutral]="response.isMissingResponse">
<td *ngIf="showGiver">{{ response.giverTeam }}</td>
<td *ngIf="showGiver">
{{ response.giver === '-' ? 'No Specific User' : response.giver }}
{{ response.giver === '-' ? 'No Specific User' : response.giver}}
{{response.giverEmail? " (" + response.giverEmail + ")" : ""}}
</td>
<td *ngIf="showRecipient">
{{ response.recipientTeam === '-' ? 'No Specific Team' : response.recipientTeam}}
</td>
<td *ngIf="showRecipient">
{{ response.recipient === '-' ? 'No Specific User' : response.recipient }}
{{ response.recipient === '-' ? 'No Specific User' : response.recipient}}
{{response.recipientEmail? " (" + response.recipientEmail + ")" : ""}}
</td>
<td>
<tm-single-response [responseDetails]="response.responseDetails" [questionDetails]="question.questionDetails"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export class ConstsumRecipientsQuestionStatisticsComponent extends ConstsumRecip

this.rowsData = Object.keys(this.pointsPerOption).map((recipient: string) => [
{ value: this.emailToTeamName[recipient] },
{ value: this.emailToName[recipient] },
{
value: this.emailToName[recipient]
+ (this.emailToTeamName[recipient] ? ` (${recipient})` : ''),
},
{ value: this.pointsPerOption[recipient].join(', ') },
{ value: this.totalPointsPerOption[recipient] },
{ value: this.averagePointsPerOption[recipient] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ContributionQuestionStatisticsComponent
this.rowsData = Object.keys(this.emailToName).map((email: string) => {
return [
{ value: this.emailToTeamName[email] },
{ value: this.emailToName[email] },
{ value: `${this.emailToName[email]} (${email})` },
{
value: statistics.results[email].claimed,
customComponent: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ export class McqQuestionStatisticsComponent extends McqQuestionStatisticsCalcula
];

this.perRecipientRowsData = Object.keys(this.perRecipientResponses).map((key: string) => {
const recipientEmail: string = this.perRecipientResponses[key].recipientEmail;
return [
{ value: this.perRecipientResponses[key].recipientTeam },
{ value: this.perRecipientResponses[key].recipient },
{
value: this.perRecipientResponses[key].recipient
+ (recipientEmail ? ` (${recipientEmail})` : ''),
},
...Object.keys(this.weightPerOption).map((option: string) => {
return {
value: this.perRecipientResponses[key].responses[option],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ export class MsqQuestionStatisticsComponent extends MsqQuestionStatisticsCalcula
];

this.perRecipientRowsData = Object.keys(this.perRecipientResponses).map((key: string) => {
const recipientEmail: string = this.perRecipientResponses[key].recipientEmail;
return [
{ value: this.perRecipientResponses[key].recipientTeam },
{ value: this.perRecipientResponses[key].recipient },
{
value: this.perRecipientResponses[key].recipient
+ (recipientEmail ? ` (${recipientEmail})` : ''),
},
...Object.keys(this.weightPerOption).map((option: string) => {
return {
value: this.perRecipientResponses[key].responses[option],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ export class NumScaleQuestionStatisticsComponent extends NumScaleQuestionStatist
for (const team of Object.keys(this.teamToRecipientToScores)) {
for (const recipient of Object.keys(this.teamToRecipientToScores[team])) {
const stats: any = this.teamToRecipientToScores[team][recipient];
const recipientEmail: string = this.recipientEmails[recipient];
this.rowsData.push([
{ value: team },
{ value: recipient },
{
value: recipient
+ (recipientEmail ? ` (${recipientEmail})` : ''),
},
{ value: stats.average },
{ value: stats.max },
{ value: stats.min },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ export class McqQuestionStatisticsCalculation

if (this.question.hasAssignedWeights) {
const perRecipientResponse: Record<string, Record<string, number>> = {};
const recipientEmails: Record<string, string> = {};
const recipientToTeam: Record<string, string> = {};
for (const response of this.responses) {
perRecipientResponse[response.recipient] = perRecipientResponse[response.recipient] || {};
recipientEmails[response.recipient] = recipientEmails[response.recipient] || response.recipientEmail || '';
for (const choice of this.question.mcqChoices) {
perRecipientResponse[response.recipient][choice] = 0;
}
Expand Down Expand Up @@ -102,6 +104,7 @@ export class McqQuestionStatisticsCalculation

this.perRecipientResponses[recipient] = {
recipient,
recipientEmail: recipientEmails[recipient],
total: +total.toFixed(5),
average: +average.toFixed(2),
recipientTeam: recipientToTeam[recipient],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ export class MsqQuestionStatisticsCalculation

const perRecipientResponse: Record<string, Record<string, number>> = {};
const recipientToTeam: Record<string, string> = {};
const recipientEmails: Record<string, string> = {};
for (const response of this.responses) {
perRecipientResponse[response.recipient] = perRecipientResponse[response.recipient] || {};
recipientEmails[response.recipient] = recipientEmails[response.recipient] || response.recipientEmail || '';
for (const choice of this.question.msqChoices) {
perRecipientResponse[response.recipient][choice] = 0;
}
Expand Down Expand Up @@ -114,6 +116,7 @@ export class MsqQuestionStatisticsCalculation

this.perRecipientResponses[recipient] = {
recipient,
recipientEmail: recipientEmails[recipient],
total: +total.toFixed(5),
average: +average.toFixed(2),
recipientTeam: recipientToTeam[recipient],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class NumScaleQuestionStatisticsCalculation
extends QuestionStatistics<FeedbackNumericalScaleQuestionDetails, FeedbackNumericalScaleResponseDetails> {

teamToRecipientToScores: Record<string, Record<string, any>> = {};
recipientEmails: Record<string, string> = {};

calculateStatistics(): void {
this.teamToRecipientToScores = {};
Expand All @@ -29,6 +30,8 @@ export class NumScaleQuestionStatisticsCalculation
answer: response.responseDetails.answer,
isSelf: giver === recipient,
});

this.recipientEmails[recipient] = this.recipientEmails[recipient] || response.recipientEmail || '';
}

for (const team of Object.keys(this.teamToRecipientToScores)) {
Expand Down
Loading

0 comments on commit 8990935

Please sign in to comment.