--- /dev/null
+import QuizQuestion from "./quiz.question";
+
+function QuizCountdown(quiz) {
+ this.quiz = quiz;
+ this.question = new QuizQuestion()
+ this.intervalCountDown = false
+}
+
+QuizCountdown.prototype = {
+
+}
+
+export default QuizCountdown;
window.$ = window.jQuery = $;
import ResizeObserver from 'resize-observer-polyfill';
+import QuizCountdown from "./quiz.countdown";
window.ResizeObserver = ResizeObserver;
// ICI tout commence vraiment
console.log(this.data.theme)
- this.timeoutAnimation = false
- this.intervalCountDown = false
- this.timeoutCountdown = false
-
//
$("#quiz").css("background-image", "url(" + this.data.theme.backgroundImage + ")")
this.resize.resize();
},
- countdown: function(res) {
- const time = this.question.current().countdown_time*1000
- if(this.question.current().countdown_enable) {
- let value = 100
- let this_ = this
- this.intervalCountDown = setInterval(function () {
- value -= (10 / time) * 100
- document.documentElement.style.setProperty("--width-bg-countdown", value + "%")
- }, 10)
-
- this.timeoutCountdown = setTimeout(function () {
- clearInterval(this_.intervalCountDown)
- this_.validateResponse(res);
- this_.updateBtnValidation("validated")
- return false
- }, time)
- }
- },
-
restart: function () {
}
this.activeScreen = null;
this.currentQuestionAnswers = [];
+ this.intervalCountDown = 0;
this.intro = new QuizScreenIntro(this);
this.outro = new QuizScreenOutro(this);
},
sendUserAnswers: function () {
+ clearInterval(this.intervalCountDown)
return this.quiz.score.setAnswer(this.quiz.question.currentPosition(), this.currentQuestionAnswers)
},
$this.resetForm();
$this.currentQuestionAnswers = [];
$this.quiz.progressbar.update();
+
+ // if countdown enable
+ if(parseInt($this.quiz.question.current().countdown_enable)) {
+ $this.countdown()
+ }
+
if (screen === 'outro') {
$this.outro.show();
}
* @param callback
*/
hideCurrentScreen: function (callback) {
+ const $this = this;
let cb = function (screen) {
if (screen.length > 0) {
$(screen).removeClass("next active-screen").addClass("none");
cb(currentScreen);
}
},
+
+ countdown: function() {
+ const $this = this;
+ const time = this.quiz.question.current().countdown_time*1000
+ let value = 100
+ this.intervalCountDown = setInterval(function () {
+ value -= (10 / time) * 100
+ document.documentElement.style.setProperty("--width-bg-countdown", value + "%")
+ if(value <= 0) {
+ clearInterval($this.intervalCountDown)
+ /**
+ *
+ * provisoire
+ */
+ let review = $this.sendUserAnswers();
+ // Si la revue instantanée est activée, on affiche les résultats
+ if ($this.quiz.data.instantReview) {
+ $this.instantReview(review);
+ } else {
+ // Sinon, on passe directement à la question suivante
+ $this.nextQuestion();
+ }
+ }
+ }, 10)
+ },
};
export default QuizScreens;
<span class="access">R</span>
</a>
@endisset
- <a class="btn primary action validate" aria-keyshortcuts="Space">
+ <a class="btn primary action validate {{$question['countdown_enable'] ? 'countdown' : ''}}" aria-keyshortcuts="Space">
<span class="text">Validate answer</span>
<span class="access space">space</span>
@isset($time)