mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-02 14:59:31 +00:00
Added delete test button and fixed link root
This commit is contained in:
@@ -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 {
|
||||||
|
await a.createTestTemplate(
|
||||||
fields.get('name'),
|
fields.get('name'),
|
||||||
fields.get('mark'));
|
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,
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user