mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 20:39:28 +00:00
Replace test data with live TestResult data
This commit is contained in:
@@ -137,10 +137,18 @@ router.all(/test\/(.{36})(\/.*)?/, async (req, res, next) => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/test/:id', (req, res) => {
|
router.get('/test/:id', async (req, res) => {
|
||||||
const t = req.test;
|
const t = req.test;
|
||||||
const linkRoot = `/admin/test/${t.id}`;
|
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', {
|
return res.render('test', {
|
||||||
title: `Stratos - ${t.template.name}`,
|
title: `Stratos - ${t.template.name}`,
|
||||||
current: 'Tests',
|
current: 'Tests',
|
||||||
@@ -152,13 +160,7 @@ router.get('/test/:id', (req, res) => {
|
|||||||
reportsLink: `${linkRoot}/reports`,
|
reportsLink: `${linkRoot}/reports`,
|
||||||
deleteLink: `${linkRoot}/delete`,
|
deleteLink: `${linkRoot}/delete`,
|
||||||
userType: req.session.userType,
|
userType: req.session.userType,
|
||||||
testResults: [ {
|
testResults: results,
|
||||||
mark: 50,
|
|
||||||
percentage: 100,
|
|
||||||
grade: 'A',
|
|
||||||
author: t.class.teachers[0].shortName,
|
|
||||||
time: new Date().toTimeString()
|
|
||||||
} ],
|
|
||||||
stats: [
|
stats: [
|
||||||
{
|
{
|
||||||
value: 19,
|
value: 19,
|
||||||
|
|||||||
Reference in New Issue
Block a user