support long answers

This commit is contained in:
Paul Zinselmeyer 2023-11-23 19:54:10 +01:00
parent 9e63bb7180
commit defa769dd2

View file

@ -6,6 +6,14 @@
<canvas id="myChart"></canvas>
<% if answers.iter().any(|x| x.len() > 4) { %>
<ol>
<% for answer in answers.iter() { %>
<li><h4><%= answer %></h4></li>
<% } %>
</ol>
<% } %>
<script>
var ctx = document.getElementById('myChart');
@ -13,9 +21,15 @@
type: 'bar',
data: {
labels: [
<% if answers.iter().any(|x| x.len() > 4) { %>
<% for answer in answers.iter().enumerate().map(|(i, _)| i+1) { %>
"<%= answer %>",
<% } %>
<% } else { %>
<% for answer in answers.iter() { %>
"<%= answer %>",
<% } %>
<% } %>
],
<% if show_result { %>
datasets: [