generic question type support
This commit is contained in:
parent
4bf6afaf4e
commit
70b0da40dc
12 changed files with 385 additions and 251 deletions
10
templates/single_choice/player.stpl
Normal file
10
templates/single_choice/player.stpl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<article>
|
||||
<h1><%= name %></h1>
|
||||
<% for (index, answer) in answers.iter().enumerate() { %>
|
||||
<form method="POST" hx-post="" hx-target="closest main">
|
||||
<input type="hidden" name="player_id" value="<%= player_id %>"></input>
|
||||
<input type="hidden" name="value" value="<%= index %>"></input>
|
||||
<button type="submit"><%= answer %></button>
|
||||
</form>
|
||||
<% } %>
|
||||
</article>
|
||||
20
templates/single_choice/result.stpl
Normal file
20
templates/single_choice/result.stpl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<% if is_correct { %>
|
||||
<article>
|
||||
<center><img src="/static/check.svg" width="50%"/></center>
|
||||
<center><h1>Correct</h1></center>
|
||||
<center><p>Your answer is correct. The correct answer is <b><%= correct_answer %></b>.</p></center>
|
||||
</article>
|
||||
<% } else { %>
|
||||
<article>
|
||||
<center><img src="/static/xmark.svg" width="50%"/></center>
|
||||
<center><h1>Wrong</h1></center>
|
||||
<center><p>
|
||||
Your answer is incorrect. The correct answer is <b><%= correct_answer %></b>.
|
||||
<% if let Some(player_answer) = player_answer { %>
|
||||
You answered <b><%= player_answer %></b>.
|
||||
<% } else { %>
|
||||
You didn't answer the question.
|
||||
<% } %>
|
||||
</p></center>
|
||||
</article>
|
||||
<% } %>
|
||||
54
templates/single_choice/viewer.stpl
Normal file
54
templates/single_choice/viewer.stpl
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<h2><%= name %></h2>
|
||||
<span>Total Participants: <b><%= total_submissions %></b></span>
|
||||
<% if show_result { %>
|
||||
<br/>
|
||||
<span>The correct answer is: <b><%= correct_answer %></b></span>
|
||||
<% } %>
|
||||
|
||||
<canvas id="myChart"></canvas>
|
||||
|
||||
|
||||
<script>
|
||||
var ctx = document.getElementById('myChart');
|
||||
var chart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: [
|
||||
<% for answer in answers.iter() { %>
|
||||
"<%= answer %>",
|
||||
<% } %>
|
||||
],
|
||||
datasets: [{
|
||||
label: "# der Stimmen",
|
||||
data: [
|
||||
<% for submissions in submissions.iter() { %>
|
||||
<%= submissions %>,
|
||||
<% } %>
|
||||
],
|
||||
borderWidth: 1
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
ticks: {
|
||||
font: {
|
||||
size: 64
|
||||
}
|
||||
}
|
||||
},
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
font: {
|
||||
size:24
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue