Skip to content

Commit

Permalink
Change per recipient stats to use email as key (#12123)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelfangjw authored Feb 22, 2023
1 parent a34c936 commit 83557c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,28 @@ export class RubricQuestionStatisticsCalculation

// calculate per recipient stats
for (const response of this.responses) {
this.perRecipientStatsMap[response.recipient] = this.perRecipientStatsMap[response.recipient] || {
recipientName: response.recipient,
recipientEmail: response.recipientEmail,
recipientTeam: response.recipientTeam,
answers: JSON.parse(JSON.stringify(emptyAnswers)),
answersSum: [],
percentages: [],
percentagesAverage: [],
weightsAverage: [],
subQuestionTotalChosenWeight: this.subQuestions.map(() => 0),
subQuestionWeightAverage: [],
};
this.perRecipientStatsMap[response.recipientEmail || response.recipient] =
this.perRecipientStatsMap[
response.recipientEmail || response.recipient
] || {
recipientName: response.recipient,
recipientEmail: response.recipientEmail,
recipientTeam: response.recipientTeam,
answers: JSON.parse(JSON.stringify(emptyAnswers)),
answersSum: [],
percentages: [],
percentagesAverage: [],
weightsAverage: [],
subQuestionTotalChosenWeight: this.subQuestions.map(() => 0),
subQuestionWeightAverage: [],
};
for (let i: number = 0; i < response.responseDetails.answer.length; i += 1) {
const subAnswer: number = response.responseDetails.answer[i];
if (subAnswer === RUBRIC_ANSWER_NOT_CHOSEN) {
continue;
}
this.perRecipientStatsMap[response.recipient].answers[i][subAnswer] += 1;
this.perRecipientStatsMap[response.recipient].subQuestionTotalChosenWeight[i] +=
this.perRecipientStatsMap[response.recipientEmail || response.recipient].answers[i][subAnswer] += 1;
this.perRecipientStatsMap[response.recipientEmail || response.recipient].subQuestionTotalChosenWeight[i] +=
+this.weights[i][subAnswer].toFixed(5);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}
],
"expectedStatsMap": {
"Alice": {
"[email protected]": {
"answers": [
[1, 1], [1, 1], [2, 0]
],
Expand All @@ -76,7 +76,7 @@
"overallWeightedSum": 2.8,
"overallWeightAverage": 0.47
},
"Bob": {
"[email protected]": {
"answers": [
[2, 0], [1, 1], [2, 0]
],
Expand Down

0 comments on commit 83557c3

Please sign in to comment.