Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#12894] Per-recipient stats are calculated based on student name, not email #12981

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,29 @@ export class MsqQuestionStatisticsCalculation
const perRecipientResponse: Record<string, Record<string, number>> = {};
const recipientToTeam: Record<string, string> = {};
const recipientEmails: Record<string, string> = {};
const recipientNames: Record<string, string> = {};
for (const response of this.responses) {
perRecipientResponse[response.recipient] = perRecipientResponse[response.recipient] || {};
recipientEmails[response.recipient] = recipientEmails[response.recipient] || response.recipientEmail || '';
if (!response.recipientEmail) {
continue;
}
perRecipientResponse[response.recipientEmail] = perRecipientResponse[response.recipientEmail] || {};
const responseEmail = response.recipientEmail;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency, responseEmail could be moved above and used in perRecipientResponse

recipientEmails[responseEmail] = recipientEmails[responseEmail] || responseEmail || '';
recipientNames[responseEmail] = recipientNames[responseEmail] || response.recipient || '';
for (const choice of this.question.msqChoices) {
perRecipientResponse[response.recipient][choice] = 0;
perRecipientResponse[responseEmail][choice] = 0;
}
if (this.question.otherEnabled) {
perRecipientResponse[response.recipient]['Other'] = 0;
perRecipientResponse[responseEmail]['Other'] = 0;
}
recipientToTeam[response.recipient] = response.recipientTeam;
recipientToTeam[responseEmail] = response.recipientTeam;
}
for (const response of this.responses) {
this.updateResponseCountPerOptionForResponse(response.responseDetails, perRecipientResponse[response.recipient]);
if (!response.recipientEmail) {
continue;
}
const email = response.recipientEmail;
this.updateResponseCountPerOptionForResponse(response.responseDetails, perRecipientResponse[email]);
}

for (const recipient of Object.keys(perRecipientResponse)) {
Expand All @@ -120,7 +130,7 @@ export class MsqQuestionStatisticsCalculation
average = numOfResponsesForRecipient ? total / numOfResponsesForRecipient : 0;

this.perRecipientResponses[recipient] = {
recipient,
recipient: recipientNames[recipient],
recipientEmail: recipientEmails[recipient],
total: +total.toFixed(5),
average: +average.toFixed(2),
Expand Down
Loading