Skip to content

Commit

Permalink
[Class statistics] Fix pass rate
Browse files Browse the repository at this point in the history
  • Loading branch information
rikurauhala committed Oct 22, 2024
1 parent 6334fe5 commit 3d5ced8
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import { CourseFilterToggle } from '../CourseFilterToggle'
import { UsePopulationCourseContext } from '../PopulationCourseContext'
import './passFailEnrollments.css'

const calculatePassRate = (total, passed) => {
if (total === 0) {
return 0
}
return (100 * passed) / total
}

export const PassFailEnrollments = ({ flat, onlyIamRights }) => {
const { modules, courseStatistics, onGoToCourseStatisticsClick, toggleGroupExpansion, expandedGroups } =
UsePopulationCourseContext()
Expand Down Expand Up @@ -96,7 +103,7 @@ export const PassFailEnrollments = ({ flat, onlyIamRights }) => {
title: 'Pass rate',
cellStyle: { textAlign: 'right' },
filterType: 'range',
getRowVal: row => row.stats?.percentageWithEnrollments ?? 0,
getRowVal: row => calculatePassRate(row.stats?.totalStudents, row.stats?.passed),
formatValue: value =>
value &&
new Intl.NumberFormat('fi-FI', {
Expand Down

0 comments on commit 3d5ced8

Please sign in to comment.