ars/templates/single_choice/viewer.stpl

106 lines
2.5 KiB
Text
Raw Normal View History

2023-11-02 22:46:38 +01:00
<h2><%= name %></h2>
<span>Total Participants: <b><%= total_submissions %></b></span>
<% if show_result { %>
<span>The correct answer is: <b><%= correct_answer %></b></span>
<% } %>
<canvas id="myChart"></canvas>
2023-11-23 19:54:10 +01:00
<% if answers.iter().any(|x| x.len() > 4) { %>
<ol>
<% for answer in answers.iter() { %>
<li><h4><%= answer %></h4></li>
<% } %>
</ol>
<% } %>
2023-11-02 22:46:38 +01:00
<script>
var ctx = document.getElementById('myChart');
var chart = new Chart(ctx, {
type: 'bar',
data: {
labels: [
2023-11-23 19:54:10 +01:00
<% 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 %>",
<% } %>
2023-11-02 22:46:38 +01:00
<% } %>
],
2023-11-05 23:01:47 +01:00
<% if show_result { %>
datasets: [
{
label: "correct answers",
data: [
<% for submissions in submissions_correct.iter() { %>
<%= submissions %>,
<% } %>
],
borderWidth: 1,
borderColor: '#fff',
backgroundColor: '#fff',
},
{
label: "wrong answers",
data: [
<% for submissions in submissions_wrong.iter() { %>
<%= submissions %>,
<% } %>
],
borderWidth: 2,
borderColor: '#fff',
backgroundColor: [ pattern.draw('diagonal-right-left', '#000000') ],
}
]
<% } else { %>
2023-11-02 22:46:38 +01:00
datasets: [{
data: [
<% for submissions in submissions.iter() { %>
<%= submissions %>,
<% } %>
],
2023-11-05 23:01:47 +01:00
borderWidth: 2,
borderColor: '#FFF',
backgroundColor: [ pattern.draw('diagonal-right-left', '#000000') ]
2023-11-02 22:46:38 +01:00
}]
2023-11-05 23:01:47 +01:00
<% } %>
2023-11-02 22:46:38 +01:00
},
options: {
2023-11-05 23:01:47 +01:00
plugins: {
legend: {
display: false
}
2023-11-02 22:46:38 +01:00
},
scales: {
x: {
2023-11-05 23:01:47 +01:00
stacked: true,
2023-11-02 22:46:38 +01:00
ticks: {
font: {
2023-11-05 23:01:47 +01:00
size: 64,
family: 'monospace'
},
color: '#FFF'
2023-11-02 22:46:38 +01:00
}
},
y: {
beginAtZero: true,
2023-11-05 23:01:47 +01:00
stacked: true,
2023-11-02 22:46:38 +01:00
ticks: {
font: {
2023-11-05 23:01:47 +01:00
size: 16,
family: 'monospace'
},
color: '#FFF'
2023-11-02 22:46:38 +01:00
}
}
}
}
});
</script>