1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-02 05:59:30 +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'); return res.redirect('/testTemplate/add');
} }
const tt = await a.createTestTemplate( try {
fields.get('name'), await a.createTestTemplate(
fields.get('mark')); 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) => { 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) => { router.get('/test/:id', async (req, res) => {
const t = await new Test(req.params.id); const t = await new Test(req.params.id);
const linkRoot = `/test/${t.id}`; const linkRoot = `/admin/test/${t.id}`;
return res.render('test', { return res.render('test', {
title: `Stratos - ${t.template.name}`, title: `Stratos - ${t.template.name}`,
@@ -130,6 +139,7 @@ router.get('/test/:id', async (req, res) => {
subject: t.class.subject.name, subject: t.class.subject.name,
maxMark: t.template.maxMark, maxMark: t.template.maxMark,
reportsLink: `${linkRoot}/reports`, reportsLink: `${linkRoot}/reports`,
deleteLink: `${linkRoot}/delete`,
testResults: [ { testResults: [ {
mark: 50, mark: 50,
percentage: 100, percentage: 100,

View File

@@ -1,4 +1,11 @@
<section class='testPage'> <section class='testPage'>
<section class='adminSection adminSection--buttons'>
{{#eq userType 'account'}}
<div class='classes__buttons'>
{{> button style='full' colour='primary' to=deleteLink content='Delete Test' size='lg'}}
</div>
{{/eq}}
</section>
<div class='adminSection'> <div class='adminSection'>
<div class='adminItem'> <div class='adminItem'>
<h2>Test Overview - {{ testName }}</h2> <h2>Test Overview - {{ testName }}</h2>