more test info

This commit is contained in:
lingdocs 2022-09-08 11:43:56 +04:00
parent 4fda7475f4
commit 4d654d0060
2 changed files with 10 additions and 6 deletions

View File

@ -154,11 +154,15 @@ const authRouter = (passport: PassportStatic) => {
const users = (await getAllLingdocsUsers()).sort((a, b) => (
(a.accountCreated || 0) - (b.accountCreated || 0)
));
const tests = new Set<string>();
users.forEach(u => u.tests.forEach(t => (
tests.add(t.id)
)));
res.render("admin", { users, tests: Array.from(tests) });
const tests: { id: string, passes: number }[] = [];
users.forEach(u => (
u.tests.forEach(({id}) => {
const ti = tests.findIndex(x => x.id === id);
if (ti > -1) tests[ti].passes++;
else tests.push({ id, passes: 0 });
})
));
res.render("admin", { users, tests });
} catch (e) {
next(e);
}

View File

@ -103,7 +103,7 @@
<div>
<h5>Tests Completed</h5>
<% for(var i=0; i < tests.length; i++) { %>
<div><%= tests[i] %></div>
<div><%= tests[i].id %>: <%= tests[i].passes =></div>
<% } %>
</div>
</div>