diff --git a/cypress/e2e/Course_statistics.js b/cypress/e2e/Course_statistics.js index 4e7177b7a..a687935ee 100644 --- a/cypress/e2e/Course_statistics.js +++ b/cypress/e2e/Course_statistics.js @@ -454,7 +454,7 @@ describe('Course Statistics tests', () => { ['Syksy 2018', null, 22, 18, 4, null, '81.82 %', '18.18 %'], ['Kevät 2018', null, 19, 12, 7, null, '63.16 %', '36.84 %'], ['Syksy 2017', null, 8, 7, 1, null, '87.50 %', '12.50 %'], - ['Kevät 2017', null, 0, 0, 0, null, '–', '0.00 %'], + ['Kevät 2017', null, 0, 0, 0, null, '–', '–'], ['Syksy 2016', null, 1, 1, 0, null, '100.00 %', '0.00 %'], ] toggleSeparateBySemesters() @@ -495,7 +495,7 @@ describe('Course Statistics tests', () => { ['Syksy 2018', null, 22, 4, 2, 1, 1, 2, 12, 0, null, '81.82 %', '18.18 %'], ['Kevät 2018', null, 19, 7, 0, 1, 0, 3, 8, 0, null, '63.16 %', '36.84 %'], ['Syksy 2017', null, 8, 1, 0, 0, 2, 2, 3, 0, null, '87.50 %', '12.50 %'], - ['Kevät 2017', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['Kevät 2017', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['Syksy 2016', null, 1, 0, 0, 0, 0, 1, 0, 0, null, '100.00 %', '0.00 %'], ] toggleShowGrades() @@ -560,7 +560,7 @@ describe('Course Statistics tests', () => { ['Syksy 2018', null, 24, 18, 6, '75.00 %', null], ['Kevät 2018', null, 20, 12, 8, '60.00 %', null], ['Syksy 2017', null, 8, 7, 1, '87.50 %', null], - ['Kevät 2017', null, 0, 0, 0, '0.00 %', 0], + ['Kevät 2017', null, 0, 0, 0, '–', 0], ['Syksy 2016', null, 1, 1, 0, '100.00 %', null], ] toggleSeparateBySemesters() @@ -658,16 +658,16 @@ describe('Course Statistics tests', () => { ['2012-2013', null, 4, 4, 0, null, '100.00 %', '0.00 %'], ['2011-2012', null, 1, 1, 0, null, '100.00 %', '0.00 %'], ['2010-2011', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['2009-2010', null, 0, 0, 0, null, '–', '0.00 %'], + ['2009-2010', null, 0, 0, 0, null, '–', '–'], ['2008-2009', null, 1, 0, 1, null, '0.00 %', '100.00 %'], ['2007-2008', null, 1, 1, 0, null, '100.00 %', '0.00 %'], ['2006-2007', null, 1, 1, 0, null, '100.00 %', '0.00 %'], ['2005-2006', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['2004-2005', null, 0, 0, 0, null, '–', '0.00 %'], + ['2004-2005', null, 0, 0, 0, null, '–', '–'], ['2003-2004', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['2002-2003', null, 0, 0, 0, null, '–', '0.00 %'], - ['2001-2002', null, 0, 0, 0, null, '–', '0.00 %'], - ['2000-2001', null, 0, 0, 0, null, '–', '0.00 %'], + ['2002-2003', null, 0, 0, 0, null, '–', '–'], + ['2001-2002', null, 0, 0, 0, null, '–', '–'], + ['2000-2001', null, 0, 0, 0, null, '–', '–'], ['1999-2000', null, 2, 2, 0, null, '100.00 %', '0.00 %'], ] checkTableContents(tableContents) @@ -698,33 +698,33 @@ describe('Course Statistics tests', () => { ['Syksy 2014', null, 3, 3, 0, null, '100.00 %', '0.00 %'], ['Kevät 2014', null, 1, 1, 0, null, '100.00 %', '0.00 %'], ['Syksy 2013', null, 1, 0, 1, null, '0.00 %', '100.00 %'], - ['Kevät 2013', null, 0, 0, 0, 0, '–', '0.00 %'], + ['Kevät 2013', null, 0, 0, 0, 0, '–', '–'], ['Syksy 2012', null, 4, 4, 0, null, '100.00 %', '0.00 %'], ['Kevät 2012', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2011', null, 0, 0, 0, 0, '–', '0.00 %'], + ['Syksy 2011', null, 0, 0, 0, 0, '–', '–'], ['Kevät 2011', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2010', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Kevät 2010', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Syksy 2009', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Kevät 2009', null, 0, 0, 0, 0, '–', '0.00 %'], + ['Syksy 2010', null, 0, 0, 0, 0, '–', '–'], + ['Kevät 2010', null, 0, 0, 0, 0, '–', '–'], + ['Syksy 2009', null, 0, 0, 0, 0, '–', '–'], + ['Kevät 2009', null, 0, 0, 0, 0, '–', '–'], ['Syksy 2008', null, 1, 0, 1, null, '0.00 %', '100.00 %'], ['Kevät 2008', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2007', null, 0, 0, 0, 0, '–', '0.00 %'], + ['Syksy 2007', null, 0, 0, 0, 0, '–', '–'], ['Kevät 2007', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2006', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Kevät 2006', null, 0, 0, 0, 0, '–', '0.00 %'], + ['Syksy 2006', null, 0, 0, 0, 0, '–', '–'], + ['Kevät 2006', null, 0, 0, 0, 0, '–', '–'], ['Syksy 2005', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['Kevät 2005', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Syksy 2004', null, 0, 0, 0, 0, '–', '0.00 %'], + ['Kevät 2005', null, 0, 0, 0, 0, '–', '–'], + ['Syksy 2004', null, 0, 0, 0, 0, '–', '–'], ['Kevät 2004', null, 1, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2003', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Kevät 2003', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Syksy 2002', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Kevät 2002', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Syksy 2001', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Kevät 2001', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Syksy 2000', null, 0, 0, 0, 0, '–', '0.00 %'], - ['Kevät 2000', null, 0, 0, 0, 0, '–', '0.00 %'], + ['Syksy 2003', null, 0, 0, 0, 0, '–', '–'], + ['Kevät 2003', null, 0, 0, 0, 0, '–', '–'], + ['Syksy 2002', null, 0, 0, 0, 0, '–', '–'], + ['Kevät 2002', null, 0, 0, 0, 0, '–', '–'], + ['Syksy 2001', null, 0, 0, 0, 0, '–', '–'], + ['Kevät 2001', null, 0, 0, 0, 0, '–', '–'], + ['Syksy 2000', null, 0, 0, 0, 0, '–', '–'], + ['Kevät 2000', null, 0, 0, 0, 0, '–', '–'], ['Syksy 1999', null, 2, 2, 0, null, '100.00 %', '0.00 %'], ] toggleSeparateBySemesters() @@ -749,16 +749,16 @@ describe('Course Statistics tests', () => { ['2012-2013', null, 4, 0, 0, 0, 0, 3, 1, 0, null, '100.00 %', '0.00 %'], ['2011-2012', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], ['2010-2011', null, 1, 0, 0, 0, 0, 1, 0, 0, null, '100.00 %', '0.00 %'], - ['2009-2010', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['2009-2010', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['2008-2009', null, 1, 1, 0, 0, 0, 0, 0, 0, null, '0.00 %', '100.00 %'], ['2007-2008', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], ['2006-2007', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], ['2005-2006', null, 1, 0, 0, 0, 0, 1, 0, 0, null, '100.00 %', '0.00 %'], - ['2004-2005', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['2004-2005', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['2003-2004', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], - ['2002-2003', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['2001-2002', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['2000-2001', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['2002-2003', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['2001-2002', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['2000-2001', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['1999-2000', null, 2, 0, 0, 0, 0, 0, 2, 0, null, '100.00 %', '0.00 %'], ] toggleShowGrades() @@ -790,33 +790,33 @@ describe('Course Statistics tests', () => { ['Syksy 2014', null, 3, 0, 0, 1, 0, 0, 2, 0, null, '100.00 %', '0.00 %'], ['Kevät 2014', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], ['Syksy 2013', null, 1, 1, 0, 0, 0, 0, 0, 0, null, '0.00 %', '100.00 %'], - ['Kevät 2013', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['Kevät 2013', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['Syksy 2012', null, 4, 0, 0, 0, 0, 3, 1, 0, null, '100.00 %', '0.00 %'], ['Kevät 2012', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2011', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['Syksy 2011', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['Kevät 2011', null, 1, 0, 0, 0, 0, 1, 0, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2010', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Kevät 2010', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Syksy 2009', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Kevät 2009', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['Syksy 2010', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Kevät 2010', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Syksy 2009', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Kevät 2009', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['Syksy 2008', null, 1, 1, 0, 0, 0, 0, 0, 0, null, '0.00 %', '100.00 %'], ['Kevät 2008', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2007', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['Syksy 2007', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['Kevät 2007', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2006', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Kevät 2006', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['Syksy 2006', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Kevät 2006', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['Syksy 2005', null, 1, 0, 0, 0, 0, 1, 0, 0, null, '100.00 %', '0.00 %'], - ['Kevät 2005', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Syksy 2004', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['Kevät 2005', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Syksy 2004', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['Kevät 2004', null, 1, 0, 0, 0, 0, 0, 1, 0, null, '100.00 %', '0.00 %'], - ['Syksy 2003', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Kevät 2003', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Syksy 2002', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Kevät 2002', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Syksy 2001', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Kevät 2001', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Syksy 2000', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], - ['Kevät 2000', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '0.00 %'], + ['Syksy 2003', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Kevät 2003', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Syksy 2002', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Kevät 2002', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Syksy 2001', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Kevät 2001', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Syksy 2000', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], + ['Kevät 2000', null, 0, 0, 0, 0, 0, 0, 0, 0, null, '–', '–'], ['Syksy 1999', null, 2, 0, 0, 0, 0, 0, 2, 0, null, '100.00 %', '0.00 %'], ] toggleShowGrades() @@ -848,16 +848,16 @@ describe('Course Statistics tests', () => { ['2012-2013', null, 4, 4, 0, '100.00 %', null], ['2011-2012', null, 1, 1, 0, '100.00 %', null], ['2010-2011', null, 1, 1, 0, '100.00 %', null], - ['2009-2010', null, 0, 0, 0, '0.00 %', null], + ['2009-2010', null, 0, 0, 0, '–', null], ['2008-2009', null, 1, 0, 1, '0.00 %', null], ['2007-2008', null, 1, 1, 0, '100.00 %', null], ['2006-2007', null, 1, 1, 0, '100.00 %', null], ['2005-2006', null, 1, 1, 0, '100.00 %', null], - ['2004-2005', null, 0, 0, 0, '0.00 %', null], + ['2004-2005', null, 0, 0, 0, '–', null], ['2003-2004', null, 1, 1, 0, '100.00 %', null], - ['2002-2003', null, 0, 0, 0, '0.00 %', null], - ['2001-2002', null, 0, 0, 0, '0.00 %', null], - ['2000-2001', null, 0, 0, 0, '0.00 %', null], + ['2002-2003', null, 0, 0, 0, '–', null], + ['2001-2002', null, 0, 0, 0, '–', null], + ['2000-2001', null, 0, 0, 0, '–', null], ['1999-2000', null, 2, 2, 0, '100.00 %', null], ] checkTableContents(tableContents) @@ -888,33 +888,33 @@ describe('Course Statistics tests', () => { ['Syksy 2014', null, 3, 3, 0, '100.00 %', null], ['Kevät 2014', null, 1, 1, 0, '100.00 %', null], ['Syksy 2013', null, 1, 0, 1, '0.00 %', null], - ['Kevät 2013', null, 0, 0, 0, '0.00 %', 0], + ['Kevät 2013', null, 0, 0, 0, '–', 0], ['Syksy 2012', null, 4, 4, 0, '100.00 %', null], ['Kevät 2012', null, 1, 1, 0, '100.00 %', null], - ['Syksy 2011', null, 0, 0, 0, '0.00 %', 0], + ['Syksy 2011', null, 0, 0, 0, '–', 0], ['Kevät 2011', null, 1, 1, 0, '100.00 %', null], - ['Syksy 2010', null, 0, 0, 0, '0.00 %', 0], - ['Kevät 2010', null, 0, 0, 0, '0.00 %', 0], - ['Syksy 2009', null, 0, 0, 0, '0.00 %', 0], - ['Kevät 2009', null, 0, 0, 0, '0.00 %', 0], + ['Syksy 2010', null, 0, 0, 0, '–', 0], + ['Kevät 2010', null, 0, 0, 0, '–', 0], + ['Syksy 2009', null, 0, 0, 0, '–', 0], + ['Kevät 2009', null, 0, 0, 0, '–', 0], ['Syksy 2008', null, 1, 0, 1, '0.00 %', null], ['Kevät 2008', null, 1, 1, 0, '100.00 %', null], - ['Syksy 2007', null, 0, 0, 0, '0.00 %', 0], + ['Syksy 2007', null, 0, 0, 0, '–', 0], ['Kevät 2007', null, 1, 1, 0, '100.00 %', null], - ['Syksy 2006', null, 0, 0, 0, '0.00 %', 0], - ['Kevät 2006', null, 0, 0, 0, '0.00 %', 0], + ['Syksy 2006', null, 0, 0, 0, '–', 0], + ['Kevät 2006', null, 0, 0, 0, '–', 0], ['Syksy 2005', null, 1, 1, 0, '100.00 %', null], - ['Kevät 2005', null, 0, 0, 0, '0.00 %', 0], - ['Syksy 2004', null, 0, 0, 0, '0.00 %', 0], + ['Kevät 2005', null, 0, 0, 0, '–', 0], + ['Syksy 2004', null, 0, 0, 0, '–', 0], ['Kevät 2004', null, 1, 1, 0, '100.00 %', null], - ['Syksy 2003', null, 0, 0, 0, '0.00 %', 0], - ['Kevät 2003', null, 0, 0, 0, '0.00 %', 0], - ['Syksy 2002', null, 0, 0, 0, '0.00 %', 0], - ['Kevät 2002', null, 0, 0, 0, '0.00 %', 0], - ['Syksy 2001', null, 0, 0, 0, '0.00 %', 0], - ['Kevät 2001', null, 0, 0, 0, '0.00 %', 0], - ['Syksy 2000', null, 0, 0, 0, '0.00 %', 0], - ['Kevät 2000', null, 0, 0, 0, '0.00 %', 0], + ['Syksy 2003', null, 0, 0, 0, '–', 0], + ['Kevät 2003', null, 0, 0, 0, '–', 0], + ['Syksy 2002', null, 0, 0, 0, '–', 0], + ['Kevät 2002', null, 0, 0, 0, '–', 0], + ['Syksy 2001', null, 0, 0, 0, '–', 0], + ['Kevät 2001', null, 0, 0, 0, '–', 0], + ['Syksy 2000', null, 0, 0, 0, '–', 0], + ['Kevät 2000', null, 0, 0, 0, '–', 0], ['Syksy 1999', null, 2, 2, 0, '100.00 %', null], ] toggleSeparateBySemesters() diff --git a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/charts/GradeDistributionChart.tsx b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/charts/GradeDistributionChart.tsx index e56cc8b46..1ba7c38d9 100644 --- a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/charts/GradeDistributionChart.tsx +++ b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/charts/GradeDistributionChart.tsx @@ -33,7 +33,7 @@ const getGradeSeries = (series: Array>) => { const newSeries = seriesType === 'thesis' ? getThesisGradeSpread(series) : getGradeSpread(series) const sumAll = calculateSumAll(newSeries) - const gradeCategories: Record = { + const gradeCategories = { thesis: ['I', 'A', 'NSLA', 'LUB', 'CL', 'MCLA', 'ECLA', 'L'], 'second-national-language': ['0', 'TT', 'HT', 'Hyv.'], 'pass-fail': ['0', 'Hyv.'], diff --git a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/charts/PassRateChart.tsx b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/charts/PassRateChart.tsx index 5890d960f..21b934b35 100644 --- a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/charts/PassRateChart.tsx +++ b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/charts/PassRateChart.tsx @@ -12,7 +12,7 @@ exporting(ReactHighcharts.Highcharts) exportData(ReactHighcharts.Highcharts) accessibility(ReactHighcharts.Highcharts) -const getPassRateAttemptSeriesFromStats = stats => { +const getPassRateAttemptSeriesFromStats = (stats: FormattedStats[]) => { const all: number[] = [] const passed: number[] = [] const failed: number[] = [] @@ -21,8 +21,8 @@ const getPassRateAttemptSeriesFromStats = stats => { stats.forEach(year => { const { passed: p, failed: f } = year.attempts.categories const { totalEnrollments } = year.attempts - const enrolledWithNoGrade = totalEnrollments > 0 ? totalEnrollments - p - f : 0 - all.push(totalEnrollments || p + f) + const enrolledWithNoGrade = totalEnrollments && totalEnrollments > 0 ? Math.max(0, totalEnrollments - p - f) : 0 + all.push(totalEnrollments ?? p + f) passed.push(p) failed.push(f) enrolledNoGrade.push(enrolledWithNoGrade) diff --git a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/tables/AttemptsTable.jsx b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/tables/AttemptsTable.jsx index 700979a86..8766f59aa 100644 --- a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/tables/AttemptsTable.jsx +++ b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/tables/AttemptsTable.jsx @@ -7,7 +7,14 @@ import { Header, Icon, Item } from 'semantic-ui-react' import { TotalsDisclaimer } from '@/components/material/TotalsDisclaimer' import { SortableTable, row } from '@/components/SortableTable' import { getCourseAlternatives } from '@/selectors/courseStats' -import { getGradeSpread, getSortableColumn, getThesisGradeSpread, isThesisGrades, resolveGrades } from '../util' +import { + formatPercentage, + getGradeSpread, + getSortableColumn, + getThesisGradeSpread, + isThesisGrades, + resolveGrades, +} from '../util' const getTableData = (stats, useThesisGrades) => stats.map(stat => { @@ -133,7 +140,7 @@ export const AttemptsTable = ({ key: 'PASSRATE', title: 'Pass rate', getRowVal: s => (s.rowObfuscated ? 'NA' : s.passRate), - getRowContent: s => (s.rowObfuscated ? 'NA' : `${Number(s.passRate || 0).toFixed(2)} %`), + getRowContent: s => (s.rowObfuscated ? 'NA' : formatPercentage(s.passRate)), }), getSortableColumn({ key: 'ENROLLMENTS', diff --git a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/tables/StudentsTable.jsx b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/tables/StudentsTable.jsx index 380da0fb4..5fc73c457 100644 --- a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/tables/StudentsTable.jsx +++ b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/tables/StudentsTable.jsx @@ -9,9 +9,7 @@ import { isDefaultServiceProvider } from '@/common' import { TotalsDisclaimer } from '@/components/material/TotalsDisclaimer' import { SortableTable, row } from '@/components/SortableTable' import { getCourseAlternatives } from '@/selectors/courseStats' -import { defineCellColor, getSortableColumn, resolveGrades } from '../util' - -const formatPercentage = passRate => (Number.isNaN(passRate) ? '–' : `${(passRate * 100).toFixed(2)} %`) +import { defineCellColor, formatPercentage, getSortableColumn, resolveGrades } from '../util' const getGradeColumns = grades => { return grades.map(({ key, title }) => @@ -133,7 +131,7 @@ const getColumns = (stats, showGrades, userHasAccessToAllStats, alternatives, se key: 'PASS_RATE', title: 'Pass rate', getRowVal: s => (s.rowObfuscated ? 0 : s.students.passRate * 100), - getRowContent: s => (s.rowObfuscated ? '5 or fewer students' : formatPercentage(s.students.passRate)), + getRowContent: s => (s.rowObfuscated ? '5 or fewer students' : formatPercentage(s.students.passRate * 100)), filterType: 'range', cellProps: s => ({ style: { @@ -147,7 +145,7 @@ const getColumns = (stats, showGrades, userHasAccessToAllStats, alternatives, se title: 'Fail rate', filterType: 'range', getRowVal: s => (s.rowObfuscated ? 'NA' : (s.students.failRate || 0) * 100), - getRowContent: s => (s.rowObfuscated ? 'NA' : formatPercentage(s.students.failRate || 0)), + getRowContent: s => (s.rowObfuscated ? 'NA' : formatPercentage(s.students.failRate * 100)), cellProps: s => ({ style: { textAlign: 'right', diff --git a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/util.ts b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/util.ts index c4ffa0cf4..435e41971 100644 --- a/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/util.ts +++ b/services/frontend/src/pages/CourseStatistics/CourseTab/SingleCourseStats/ResultTabs/tabs/util.ts @@ -73,7 +73,7 @@ export const getSeriesType = (series: Array>) => { } export const absoluteToRelative = (all: number[]) => (p: number, i: number) => { - return parseFloat(calculatePercentage(p, all[i]).slice(0, -1)) + return Math.min(100, parseFloat(calculatePercentage(p, all[i]).slice(0, -1))) } const gradesOrder = { @@ -271,3 +271,7 @@ export const getGraphOptions = ( }, }, }) + +export const formatPercentage = (rate: number) => { + return Number.isNaN(rate) ? '–' : `${rate.toFixed(2)} %` +}