1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 22:39:26 +00:00

Added class stat data, and amended pluralisation logic

This commit is contained in:
2022-03-06 20:36:21 +00:00
parent fcd37ed1fd
commit e94f8ef94c
2 changed files with 18 additions and 12 deletions

View File

@@ -26,17 +26,18 @@ router.get('/dashboard', async (req, res) => {
stats: [ stats: [
{ {
value: classes.length, value: classes.length,
text: 'Class' + (classes.length > 1 ? 'es' : '') text: 'Class' +
(classes.length !== 1 ? 'es' : '')
}, },
{ {
value: recentTests.length, value: recentTests.length,
text: 'Completed Test' + text: 'Completed Test' +
(recentTests.length > 1 ? 's' : '') (recentTests.length !== 1 ? 's' : '')
}, },
{ {
value: upcomingTests.length, value: upcomingTests.length,
text: 'Upcoming Test' + text: 'Upcoming Test' +
(upcomingTests.length > 1 ? 's' : '') (upcomingTests.length !== 1 ? 's' : '')
}, },
{ {
value: '90%', value: '90%',

View File

@@ -35,31 +35,36 @@ router.get('/class/:id', async (req, res) => {
return res.redirect('/admin/classes'); return res.redirect('/admin/classes');
const linkRoot = `/class/${c.id}`; const linkRoot = `/class/${c.id}`;
const upcomingTests = await c.getTests({ range: 'after' });
const recentTests = await c.getTests({ range: 'before' });
const testCount = recentTests.length + upcomingTests.length;
return res.render('class', { return res.render('class', {
title: `Stratos - Class - ${c.name}`, title: `Stratos - ${c.name}`,
current: 'Classes', current: 'Classes',
name: req.session.fullName, name: req.session.fullName,
className: c.name, className: c.name,
teachers: c.teachers, teachers: c.teachers,
members: c.students, members: c.students,
recentTests: await c.getTests({ range: 'before' }), recentTests: recentTests,
upcomingTests: await c.getTests({ range: 'after' }), upcomingTests: upcomingTests,
contactLink: `${linkRoot}/contact`, contactLink: `${linkRoot}/contact`,
testsLink: `${linkRoot}/tests`, testsLink: `${linkRoot}/tests`,
reportsLink: `${linkRoot}/reports`, reportsLink: `${linkRoot}/reports`,
stats: [ stats: [
{ {
value: 5, value: testCount,
text: 'Tests' text: 'Test' + (testCount !== 1 ? 's' : '')
}, },
{ {
value: 3, value: recentTests.length,
text: 'Tests completed' text: 'Completed test' +
(recentTests.length !== 1 ? 's' : '')
}, },
{ {
value: 2, value: upcomingTests.length,
text: 'Tests upcoming' text: 'Upcoming test' +
(upcomingTests.length !== 1 ? 's' : '')
}, },
{ {
value: '72%', value: '72%',