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

Split out singleTest route and fix priorities for routes

This commit is contained in:
2022-04-18 15:00:50 +00:00
parent 9f9354fcb1
commit 28ac0df520
4 changed files with 62 additions and 48 deletions

View File

@@ -137,56 +137,9 @@ router.all(/test\/(.{36})(\/.*)?/, async (req, res, next) => {
next();
});
router.get('/test/:id', async (req, res) => {
const t = req.test;
const linkRoot = `/admin/test/${t.id}`;
let results = await t.getTestResults();
if (req.session.userType === 'student') {
results = results.filter(r =>
r.student.id === req.session.userId
);
}
return res.render('test', {
title: `Stratos - ${t.template.name}`,
current: 'Tests',
name: req.session.fullName,
testName: t.template.name,
class: t.class,
subject: t.class.subject.name,
maxMark: t.template.maxMark,
reportsLink: `${linkRoot}/reports`,
deleteLink: `${linkRoot}/delete`,
userType: req.session.userType,
testResults: results,
stats: [
{
value: 19,
text: 'Results submitted'
},
{
value: '30%',
text: 'Average score'
},
{
value: 1,
text: 'Placeholder'
},
{
value: '2',
text: 'Placeholder'
},
{
value: '3',
text: 'Placeholder'
},
]
});
});
module.exports = {
priority: 30,
root: '/admin',
router: router
};