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

Extend educational material summary #2017

Merged
merged 16 commits into from
Oct 12, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
#2004-rounding off the numbers in average
Brajesh Kumar authored and Brajesh Kumar committed Oct 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 3a38701dad07a86f5a721b4cd979e13ec575defd
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ export class EducationalMaterialComponent implements OnInit {
updateSummary() {
const summary = new Map<string, { count: number; sum: number }>();
const average = new Map<string, number>();

// Initialize summary and average maps in a single loop
for (const m of this.records) {
if (m.materialType) {
@@ -119,9 +119,9 @@ export class EducationalMaterialComponent implements OnInit {
const avgSummaryArray: string[] = [];

for (const [label, labelData] of summary.entries()) {
const avg = labelData.sum / labelData.count;
const avg = parseFloat((labelData.sum / labelData.count).toPrecision(2));
average.set(label, avg);

summaryArray.push(`${label}: ${labelData.sum}`);
avgSummaryArray.push(`${label}: ${avg}`);
}