1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 15:59:25 +00:00

Added class route, contains mostly real data but some test data too

This commit is contained in:
2022-03-03 02:17:53 +00:00
parent 2eafa45b9d
commit 959576585d

View File

@@ -3,6 +3,7 @@
const express = require('express');
const router = express.Router();
const Class = require('../lib/Class');
const User = require('../lib/User');
router.get('/classes', async (req, res) => {
@@ -16,6 +17,47 @@ router.get('/classes', async (req, res) => {
});
});
router.get('/class/:id', async (req, res) => {
const c = await new Class(req.params.id);
const linkRoot = `/class/${c.id}`;
return res.render('class', {
title: `Stratos - Class - ${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' }),
contactLink: `${linkRoot}/contact`,
testsLink: `${linkRoot}/tests`,
reportsLink: `${linkRoot}/reports`,
stats: [
{
value: 5,
text: 'Tests'
},
{
value: 3,
text: 'Tests completed'
},
{
value: 2,
text: 'Tests upcoming'
},
{
value: '72%',
text: 'Average percentage'
},
{
value: '50%',
text: 'Last percentage'
},
]
});
});
module.exports = {
root: '/admin',
router: router