Skip to content

Commit

Permalink
Fix deux/trois soucis sur les quizz
Browse files Browse the repository at this point in the history
  • Loading branch information
artragis committed Oct 30, 2022
1 parent 15c9c8e commit db80c8d
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 1,225 deletions.
20 changes: 14 additions & 6 deletions assets/js/content-quizz.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ function extractAnswer(radio, answers) {
} else {
answers[rb.parentNode.parentNode.getAttribute('id')].push(rb.checked)
}
console.log('is checked')
console.log(rb.checked)
rb.setAttribute('value', answers[rb.parentNode.parentNode.getAttribute('id')].length - 1)
rb.disabled = false
rb.checked = false
Expand Down Expand Up @@ -48,10 +46,8 @@ function computeForm(formdata, answers) {
console.log('not found ' + name)
continue
} else {
console.log(name + ' ' + values + ' : ' + answers[name][values])
// for poc we assume we only deal with lists
if (!answers[name][values]) {
console.log('bad answer ' + name + ' ' + values)
badAnswers.push({
name: name,
value: values
Expand Down Expand Up @@ -210,10 +206,13 @@ document.querySelectorAll('form.quizz').forEach(form => {
}
let nbGood = 0
let nbTotal = 0
console.log(answers)
Object.keys(answers).forEach(name => {
const element = document.querySelector(`.custom-block[data-name="${name}"]`)
let title = element.querySelector('.custom-block-heading').textContent
const correction = element.querySelector('.custom-block-heading+div')
const correction = element.querySelector('.custom-block-body .custom-block')
console.log(correction)
console.log(title)
if (correction && title.indexOf(correction.textContent) > 0) {
title = title.substr(0, title.indexOf(correction.textContent))
}
Expand All @@ -224,14 +223,23 @@ document.querySelectorAll('form.quizz').forEach(form => {
statistics.expected[title] = {}
const availableResponses = element.querySelectorAll('input')
for (let i = 0; i < availableResponses.length; i++) {
statistics.expected[title][availableResponses[i].parentElement.textContent] = answers[name][i]
let questionLabel = availableResponses[i].parentElement.textContent;
console.log(questionLabel)
console.log(questionLabel.indexOf(correction.textContent))
if (correction && questionLabel.indexOf(correction.textContent) !== -1) {
questionLabel = questionLabel.substring(0, questionLabel.indexOf(correction.textContent))
}
statistics.expected[title][questionLabel] = answers[name][i]
}
// now determine answers and their labels
element.querySelectorAll('input:checked')
.forEach(node => {
// remove eventual glued corretion
let label = node.parentElement.textContent
if (correction && label.indexOf(correction.textContent) !== -1) {
label = label.substr(0, label.indexOf(correction.textContent))
}

statistics.result[title].labels.push(label.trim())
})
if (element.classList.contains('hasAnswer')) {
Expand Down
19 changes: 0 additions & 19 deletions templates/tutorialv2/includes/child.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@
{% trans "Ajouter une section" %}
</a>
</li>
<li class="simple-create-button">
<a class="btn btn-grey" href="{% if child.parent == content %}
{% url "content:create-quizz" content.pk content.slug child.slug %}
{% else %}
{% url "content:create-quizz" content.pk content.slug child.parent.slug child.slug %}
{% endif %}">
{% trans "Ajouter un quizz" %}
</a>
</li>
{% endif %}
</ol>
{% elif child.has_sub_containers %}
Expand Down Expand Up @@ -157,13 +148,6 @@ <h4>
>{% trans "Ajouter une section" %}</a>
</h4>
</li>
<li class="simple-create-button">
<h4>
<a class="btn btn-grey"
href="{% url "content:create-quizz" content.pk child.parent.slug child.slug subchild.slug %}"
>{% trans "Ajouter un quizz" %}</a>
</h4>
</li>
{% endif %}
</ol>
</li>
Expand Down Expand Up @@ -206,9 +190,6 @@ <h3>
<li class="simple-create-button">
<a class="btn btn-grey" href="{% url "content:create-extract" content.pk content.slug child.parent.slug child.slug %}">
{% trans "Ajouter une section" %}
</a> {% trans 'ou' %}
<a class="btn btn-grey" href="{% url "content:create-quizz" content.pk content.slug child.parent.slug child.slug %}">
{% trans "ajouter un quizz" %}
</a>
</li>
</ol>
Expand Down
6 changes: 6 additions & 0 deletions templates/tutorialv2/stats/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ <h2 class="ico-after ico-tutorials">
{% include "misc/graph.part.html" with tab_name="tab-visit-time-graph-content" graph_title="Évolution du temps moyen lecture (en secondes)" canvas_id="visit-time-graph" report_key="avg_time_on_page" y_label="Secondes" %}
{% include "misc/graph.part.html" with tab_name="tab-users-graph-content" graph_title="Évolution du nombre de visiteurs uniques" canvas_id="users-graph" report_key="nb_uniq_visitors" y_label="Nombre de visiteurs" %}
{% include "misc/quizz.graph.part.html" with tab_name="tab-quizz-content" graph_title="Réponses au quizz" canvas_id="quizz-graph" metric="quizz" %}
{% else %}
<div class="tab">
<span class="tablinks" tabindex="0" id="tab-quizz">{% trans "Quizz" %}</span>
</div>
{% include "misc/quizz.graph.part.html" with tab_name="tab-quizz-content" graph_title="Réponses au quizz" canvas_id="quizz-graph" metric="quizz" %}

{% endif %}

{% if cumulative_stats %}
Expand Down
16 changes: 0 additions & 16 deletions templates/tutorialv2/view/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ <h1>
{% trans "Ajouter une section" %}
</a>
</li>
<li class="simple-create-button">
<a class="btn btn-grey" href="{% if container.parent == content %}
{% url "content:create-quizz" content.pk content.slug container.slug %}
{% else %}
{% url "content:create-quizz" content.pk content.slug container.parent.slug container.slug %}
{% endif %}">
{% trans "Ajouter un quizz" %}
</a>
</li>
{% endif %}
</ul>
{% endif %}
Expand Down Expand Up @@ -212,13 +203,6 @@ <h2 class="force-blue">
{% url "content:create-extract" content.pk content.slug container.parent.slug container.slug %}
{% endif %}">
{% trans "Ajouter une section" %}
</a> {% trans 'ou' %}
<a href="{% if container.parent == content %}
{% url "content:create-quizz" content.pk content.slug container.slug %}
{% else %}
{% url "content:create-quizz" content.pk content.slug container.parent.slug container.slug %}
{% endif %}">
{% trans "ajouter un quizz" %}
</a>
<div class="actions-title">
<a href="{% if container.parent == content %}
Expand Down
11 changes: 0 additions & 11 deletions templates/tutorialv2/view/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ <h2 class="subtitle">
{% trans "Ajouter une section" %}
</a>
</li>
<li class="simple-create-button">
<a class="btn btn-grey" href="{% url "content:create-quizz" content.pk content.slug %}">
{% trans "Ajouter un quizz" %}
</a>
</li>
{% endif %}
</ul>
{% endif %}
Expand Down Expand Up @@ -235,9 +230,6 @@ <h2>
<h2>
<a class="force-blue" href="{% url "content:create-extract" content.pk content.slug %}">
{% trans "Ajouter une section" %}
</a> {% trans 'ou'%}
<a class="force-blue" href="{% url "content:create-quizz" content.pk content.slug %}">
{% trans "ajouter un quizz" %}
</a>
<div class="actions-title">
<a href="{% url "content:create-extract" content.pk content.slug %}" class="ico-after more btn btn-grey">
Expand Down Expand Up @@ -291,9 +283,6 @@ <h2>
<a href="{% url "content:create-extract" content.pk content.slug %}" class="ico-after more blue new-btn">
{% trans "Ajouter une section" %}
</a>
<a href="{% url "content:create-quizz" content.pk content.slug %}" class="ico-after more blue new-btn">
{% trans "Ajouter un quizz" %}
</a>
{% endif %}

<a href="{% url "content:import" content.pk content.slug %}" class="ico-after import blue new-btn">
Expand Down
Loading

0 comments on commit db80c8d

Please sign in to comment.