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/question.eta
2023-03-10 16:41:57 +02:00

38 lines
1.2 KiB
Plaintext

<% layout("./layouts/layout.eta") %>
<h1>Question <%= it.id %>: <%= it.question_text %></h1>
<h2>All options:</h2>
<% if (it.details && it.details.length > 0) { %>
<% it.details.forEach((item) => { %>
<p><form action="/topics/<%= it.topicId %>/questions/<%= it.id %>/options/<%= item.id %>/delete" method="POST">
Content: <%= item.option_text %>; Correctness: <%= item.is_correct %>
<input type="submit" value="Delete pption" />
</form></p>
<% }); %>
<% } else { %>
<p>No option available. Do you want to delete this question?</p>
<form method="POST" action="/topics/<%= it.topicId %>/questions/<%= it.id %>/delete">
<input type="submit" value="Delete Question"/>
</form>
<% } %>
<h2>Add an answer pption</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/<%= it.id %>/options">
Option:<br/>
<textarea name="option_text"><%= it.optionText ? it.optionText : "" %></textarea><br/>
Correct:
<input type="checkbox" name="correct"/>
<input type="submit" value="Add"/>
</form>