mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 16:19:26 +00:00
Added class stat data, and amended pluralisation logic
This commit is contained in:
@@ -26,17 +26,18 @@ router.get('/dashboard', async (req, res) => {
|
||||
stats: [
|
||||
{
|
||||
value: classes.length,
|
||||
text: 'Class' + (classes.length > 1 ? 'es' : '')
|
||||
text: 'Class' +
|
||||
(classes.length !== 1 ? 'es' : '')
|
||||
},
|
||||
{
|
||||
value: recentTests.length,
|
||||
text: 'Completed Test' +
|
||||
(recentTests.length > 1 ? 's' : '')
|
||||
(recentTests.length !== 1 ? 's' : '')
|
||||
},
|
||||
{
|
||||
value: upcomingTests.length,
|
||||
text: 'Upcoming Test' +
|
||||
(upcomingTests.length > 1 ? 's' : '')
|
||||
(upcomingTests.length !== 1 ? 's' : '')
|
||||
},
|
||||
{
|
||||
value: '90%',
|
||||
|
||||
@@ -35,31 +35,36 @@ router.get('/class/:id', async (req, res) => {
|
||||
return res.redirect('/admin/classes');
|
||||
|
||||
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', {
|
||||
title: `Stratos - Class - ${c.name}`,
|
||||
title: `Stratos - ${c.name}`,
|
||||
current: 'Classes',
|
||||
name: req.session.fullName,
|
||||
className: c.name,
|
||||
teachers: c.teachers,
|
||||
members: c.students,
|
||||
recentTests: await c.getTests({ range: 'before' }),
|
||||
upcomingTests: await c.getTests({ range: 'after' }),
|
||||
recentTests: recentTests,
|
||||
upcomingTests: upcomingTests,
|
||||
contactLink: `${linkRoot}/contact`,
|
||||
testsLink: `${linkRoot}/tests`,
|
||||
reportsLink: `${linkRoot}/reports`,
|
||||
stats: [
|
||||
{
|
||||
value: 5,
|
||||
text: 'Tests'
|
||||
value: testCount,
|
||||
text: 'Test' + (testCount !== 1 ? 's' : '')
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
text: 'Tests completed'
|
||||
value: recentTests.length,
|
||||
text: 'Completed test' +
|
||||
(recentTests.length !== 1 ? 's' : '')
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
text: 'Tests upcoming'
|
||||
value: upcomingTests.length,
|
||||
text: 'Upcoming test' +
|
||||
(upcomingTests.length !== 1 ? 's' : '')
|
||||
},
|
||||
{
|
||||
value: '72%',
|
||||
|
||||
Reference in New Issue
Block a user