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

View File

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