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

Added delete test button and fixed link root

This commit is contained in:
2022-03-21 09:18:29 +00:00
parent afbb7485dc
commit 31507e13fd
2 changed files with 22 additions and 5 deletions

View File

@@ -91,11 +91,20 @@ router.post('/testTemplate/add', async (req, res) => {
return res.redirect('/testTemplate/add');
}
const tt = await a.createTestTemplate(
fields.get('name'),
fields.get('mark'));
try {
await a.createTestTemplate(
fields.get('name'),
fields.get('mark'));
} catch (e) {
return res.render('error', {
title: 'Stratos - Error',
current: 'Tests',
name: req.session.fullName,
msg: 'Could not create test template'
});
}
return res.json(tt);
return res.redirect('/admin/test/add');
});
router.get(/test\/(.{36})(\/.*)?/, async (req, res, next) => {
@@ -119,7 +128,7 @@ router.get(/test\/(.{36})(\/.*)?/, async (req, res, next) => {
});
router.get('/test/:id', async (req, res) => {
const t = await new Test(req.params.id);
const linkRoot = `/test/${t.id}`;
const linkRoot = `/admin/test/${t.id}`;
return res.render('test', {
title: `Stratos - ${t.template.name}`,
@@ -130,6 +139,7 @@ router.get('/test/:id', async (req, res) => {
subject: t.class.subject.name,
maxMark: t.template.maxMark,
reportsLink: `${linkRoot}/reports`,
deleteLink: `${linkRoot}/delete`,
testResults: [ {
mark: 50,
percentage: 100,