ars/templates/single_choice/viewer.stpl

92 lines
2.1 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>
<script>
var ctx = document.getElementById('myChart');
var chart = new Chart(ctx, {
type: 'bar',
data: {
labels: [
<% for answer in answers.iter() { %>
"<%= answer %>",
<% } %>
],
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>