Dear Mr. Sansonetti,
I to use the code and it worked fine. When I tried to do a single counter per question using atto_templates and filter_filtercodes it stopped working.
Here is the code. Can you please tell me where it is wrong? Thank you in advance
<center>
<!-- <h3> <p style="text-align: right;"><b>Time left for the entire exam is </b><span id="quiz-time-left">0:00:00</span></p></h3>
<h2> <p style="text-align: center;"><b>Question No: 1</b></p></h2>
-->
<div style="text-align:center" class="sticky">
<h4>Il tempo dedicato a questa domanda è 30 secondi, cortesemente rispondi a tutte le domande.
</h4>
<h3><span id="displayDiv" class="label label-danger"></span></h3>
</div>
<script>
<!-- const COUNTER_KEY%7Bquestion_id%7D = 'my-counter'; -->
const COUNTER_KEY % 7 B {
question_id
} % 7 D = 'my-counter%7D{question_id}%7D';
function countDown(i, callback) {
//callback = callback || function(){};
timer = setInterval(function() {
minutes = parseInt(i / 60, 10);
seconds = parseInt(i % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
document.getElementById("displayDiv").innerHTML = "Tempo rimasto: " + "0:" + minutes + ":" + seconds;
if ((i--) > 0) {
window.sessionStorage.setItem(COUNTER_KEY % 7 B {
question_id
} % 7 D, i);
} else {
window.sessionStorage.removeItem(COUNTER_KEY % 7 B {
question_id
} % 7 D);
clearInterval(timer);
callback();
}
}, 1000);
}
if (document.location.href.indexOf('review') === -1) {
window.onload = function() {
var countDownTime = window.sessionStorage.getItem(COUNTER_KEY % 7 B {
question_id
} % 7 D) || 30; <!-- originalmente 360 Indica i secondi -->
countDown(countDownTime, function() {
document.getElementsByClassName("mod_quiz-next-nav btn btn-primary")[0].click();
});
};
}
</script>
</center>