This repository has been archived on 2025-12-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
quizzy-application/drill-and-practice/views/questions.eta
2023-03-10 16:41:57 +02:00

36 lines
897 B
Plaintext

<% layout("./layouts/layout.eta") %>
<h1>Topic <%= it.topicId %>: <%= it.topicName %></h1>
<h2>All topic questions</h2>
<% if (it.currentQuestions && it.currentQuestions.length > 0) { %>
<ul>
<% it.currentQuestions.forEach(item => { %>
<p><li>
<a href="/topics/<%= it.topicId %>/questions/<%= item.id %>"><%= item.question_text %></a>
</li></p>
<% }); %>
</ul>
<% } else { %>
<p>No question available for this topic.</p>
<% } %>
<h2>Add a question</h2>
<% if (it.errors) { %>
<ul>
<% Object.keys(it.errors).forEach((error) => { %>
<% Object.values(it.errors[error]).forEach((err) => { %>
<li><%= err %></li>
<% }); %>
<% }); %>
</ul>
<% } %>
<form method="POST" action="/topics/<%= it.topicId %>/questions">
Text:<br/>
<textarea name="question_text"><%= it.question ? it.question : "" %></textarea><br/>
<input type="submit" value="Add"/>
</form>