Major bug fix
This commit is contained in:
37
drill-and-practice/views/question.eta
Normal file
37
drill-and-practice/views/question.eta
Normal file
@@ -0,0 +1,37 @@
|
||||
<% 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>
|
||||
35
drill-and-practice/views/questions.eta
Normal file
35
drill-and-practice/views/questions.eta
Normal file
@@ -0,0 +1,35 @@
|
||||
<% 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>
|
||||
|
||||
14
drill-and-practice/views/quiz.eta
Normal file
14
drill-and-practice/views/quiz.eta
Normal file
@@ -0,0 +1,14 @@
|
||||
<% layout("./layouts/layout.eta") %>
|
||||
|
||||
<h2>Question: <%= it.question %></h2>
|
||||
|
||||
<h2>Answer options:</h2>
|
||||
<% if (it.answers && it.answers.length > 0) { %>
|
||||
<% it.answers.forEach(answer => { %>
|
||||
<p><form action="/quiz/<%= it.topicId %>/questions/<%= it.questionId %>/options/<%= answer.id %>" method="POST">
|
||||
<%= answer.option_text %><input type="submit" value="Choose" />
|
||||
</form></p>
|
||||
<% }); %>
|
||||
<% } else { %>
|
||||
<p>There is no answer option for this question.</p>
|
||||
<% } %>
|
||||
18
drill-and-practice/views/quizTopics.eta
Normal file
18
drill-and-practice/views/quizTopics.eta
Normal file
@@ -0,0 +1,18 @@
|
||||
<% layout("./layouts/layout.eta") %>
|
||||
<h1>Quiz</h1>
|
||||
|
||||
<h2>All available topics</h2>
|
||||
|
||||
<% if (it.topics && it.topics.length > 0) { %>
|
||||
<ul>
|
||||
<% it.topics.forEach(topic => { %>
|
||||
<p>
|
||||
<li>
|
||||
<a href="/quiz/<%= item.id %>"><%= item.name %></a>
|
||||
</li>
|
||||
</p>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% } else { %>
|
||||
<p>No available topics.</p>
|
||||
<% } %>
|
||||
42
drill-and-practice/views/topics.eta
Normal file
42
drill-and-practice/views/topics.eta
Normal file
@@ -0,0 +1,42 @@
|
||||
<% layout("./layouts/layout.eta") %>
|
||||
<h1>Topics</h1>
|
||||
|
||||
<h2>All available topics</h2>
|
||||
|
||||
<% if (it.topics && it.topics.length > 0) { %>
|
||||
<ul>
|
||||
<% it.topics.forEach(item => { %>
|
||||
<p>
|
||||
<li>
|
||||
<a href="/topics/<%= item.id %>"><%= item.name %></a>
|
||||
<% if (it.admin) { %>
|
||||
<form action="/topics/<%= item.id %>/delete" method="POST">
|
||||
<input type="submit" value="Delete" />
|
||||
<% } %>
|
||||
</li>
|
||||
</p>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% } else { %>
|
||||
<p>No available topics.</p>
|
||||
<% } %>
|
||||
|
||||
<% if (it.errors) { %>
|
||||
<h2>Add a Topic</h2>
|
||||
<ul>
|
||||
<% Object.keys(it.errors).forEach((error) => { %>
|
||||
<% Object.values(it.errors[error]).forEach((err) => { %>
|
||||
<li><%= err %></li>
|
||||
<% }); %>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% } %>
|
||||
|
||||
<% if (it.admin) { %>
|
||||
<form method="POST" action="/topics">
|
||||
Name:<br/>
|
||||
<input type="text" name="name" value="<%= it.name ? it.name : "" %>"/><br/>
|
||||
<input type="submit" value="Add"/>
|
||||
</form>
|
||||
<% } %>
|
||||
|
||||
Reference in New Issue
Block a user