PageSourceSearch

https://braintests.net/wp-content/plugins/quiz-maker/public/js/quiz-maker-public.js?ver=1790906462

js braintests.net collected 2026-10-02 02:02:50 UTC 329,272 bytes, 5,529 lines download raw bytes

1(function ($) {
2    'use strict';
3    $(document).ready(function () {
4        $.fn.goTo = function(myOptions) {
5            var QuizAnimationTop = (myOptions.quiz_animation_top && myOptions.quiz_animation_top != 0) ? parseInt(myOptions.quiz_animation_top) : 100;
6
7            myOptions.quiz_enable_animation_top = myOptions.quiz_enable_animation_top ? myOptions.quiz_enable_animation_top : 'on';
8            var EnableQuizAnimationTop = ( myOptions.quiz_enable_animation_top && myOptions.quiz_enable_animation_top == 'on' ) ? true : false;
9            if( EnableQuizAnimationTop ){
10                $('html, body').animate({
11                    scrollTop: $(this).offset().top - QuizAnimationTop + 'px'
12                }, 'slow');
13            }
14            return this; // for chaining...
15        }
16        if (!String.prototype.trim) {
17            (function() {
18                String.prototype.trim = function() {
19                    return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
20                };
21            })();
22        }
23
24        $(document).find('.for_quiz_rate_avg.ui.rating').rating('disable');
25
26        var ays_quiz_container, ays_quiz_container_id, quizId; //flag to prevent quick multi-click glitches
27        var myOptions, myQuizOptions, explanationTimeout;
28        var emailValivatePattern = /^[a-zA-Z0-9\._+-]+@[a-zA-Z0-9\._-]+\.\w{2,}$/;
29        var aysThisQuizBullets = null;
30        var aysThisQuizQuestionsFirstPass = true;
31        var AYS_MS_PER_SECONDS = 1000;
32        var aysDurationInSeconds = 2;
33        if( typeof window.aysQuizBullets == 'undefined' ){
34            window.aysQuizBullets = [];
35        }
36
37        if( typeof window.aysQuizQuestionTimers == 'undefined' ){
38            window.aysQuizQuestionTimers = [];
39        }
40
41        if( typeof window.aysSeeResultConfirmBox == 'undefined' ){
42            window.aysSeeResultConfirmBox = [];
43        }
44
45        if( typeof window.aysEarlyFinishConfirmBox == 'undefined' ){
46            window.aysEarlyFinishConfirmBox = [];
47        }
48
49
50        window.aysTimerInterval = null;
51        window.countdownTimeForShowInterval = null;
52        window.aysQuizStartDate = null;
53        window.voiceAction = false;
54
55        function aysQuizResizeIframe(iframe) {
56            iframe.height = iframe.contentWindow.document.body.scrollHeight + 40;
57            window.requestAnimationFrame(function(){ aysQuizResizeIframe(iframe) });
58        }
59
60        $(document).find('.ays-quiz-container[data-is-embed="1"]').each(function () {
61            if (Number(this.dataset.isAmp) === 0 && Number(this.dataset.isEmbed) === 1) {
62                // var iframes = window.parent.document.querySelectorAll('iframe[id^="aysQuizIframe"]');
63                // if( iframes ) {
64                //     for (var i = 0; i < iframes.length; i++) {
65                //         aysQuizResizeIframe(iframes[i]);
66                //     }
67                // }
68            }
69        });
70
71        if( $(document).find('.ays-quiz-container[data-is-amp="1"]').length > 0 ) {
72            aysResizeiFrame();
73        }
74
75        function time_limit(e) {
76            quizId = $(e.target).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
77            myOptions = JSON.parse(atob(window.aysQuizOptions[quizId]));
78
79            if(checkQuizPassword(e, myOptions, false) === false){
80                return false;
81            }
82
83            if(typeof myOptions.answers_rw_texts == 'undefined'){
84                myOptions.answers_rw_texts = 'on_passing';
85            }
86            if(typeof myOptions.make_questions_required == 'undefined'){
87                myOptions.make_questions_required = 'off';
88            }
89            var quizOptionsName = 'quizOptions_'+quizId;
90            myQuizOptions = [];
91            if(typeof window[quizOptionsName] !== 'undefined'){
92                for(var i in window[quizOptionsName]){
93                    if(window[quizOptionsName].hasOwnProperty(i)){
94                        myQuizOptions[i] = (JSON.parse(window.atob(window[quizOptionsName][i])));
95                    }
96                }
97            }
98            
99            if(typeof window.aysSeeResultConfirmBox !== 'undefined'){
100                window.aysSeeResultConfirmBox[ quizId ] = false;
101            }
102
103            if(typeof window.aysEarlyFinishConfirmBox !== 'undefined'){
104                window.aysEarlyFinishConfirmBox[ quizId ] = false;
105            }
106
107            var container = $(e.target).parents('.ays-quiz-container');
108            if ($(this).parents('.step').next().find('.information_form').length === 0 ){
109                var quizMusic = container.find('audio.ays_quiz_music');
110                if(quizMusic.length !== 0){                
111                    var soundEls = $(document).find('.ays_music_sound');
112                    container.find('.ays_music_sound').removeClass('ays_display_none');
113                    if(!isPlaying(quizMusic.get(0))){
114                        container.find('audio.ays_quiz_music')[0].play();
115                        audioVolumeIn($(e.target).parents('.ays-quiz-container').find('audio.ays_quiz_music')[0]);
116                    }
117                }
118                container.find('.ays-live-bar-wrap').css({'display': 'block'});
119                container.find('.ays-live-bar-percent').css({'display': 'inline-block'});
120                container.find('input.ays-start-date').val(GetFullDateTime());
121                window.aysQuizStartDate = GetFullDateTime();
122            }
123            if ($(this).parents('.step').next().find('.information_form').length === 0 && myOptions.enable_timer == 'on') {
124                var questionCountPerPage = myOptions.question_count_per_page && myOptions.question_count_per_page === 'on';
125                var displayALlQuestion = myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions === 'on';
126                if( displayALlQuestion ){
127                    myOptions.quiz_timer_type = 'quiz_timer';
128                } else if ( questionCountPerPage ) {
129                    myOptions.quiz_timer_type = 'quiz_timer';
130                }
131
132                var timerType = myOptions.quiz_timer_type ? myOptions.quiz_timer_type : 'quiz_timer';
133                if( timerType === 'quiz_timer' ){
134                    quizTimer( container );
135                }else if( timerType === 'question_timer' ){
136                    if( myOptions.quiz_waiting_time && myOptions.quiz_waiting_time === 'on' ){
137                        myOptions.quiz_waiting_time = 'off';
138                    }
139                    questionTimerInit( container );
140                }
141            }else{
142                $(this).parents('.step').next().find('.information_form').find('.ays_next.action-button').on('click', function () {
143                    if($(this).parents('.step').find('.information_form').find('.ays_next.action-button').hasClass('ays_start_allow')){
144                        time_limit(e);                        
145                    }
146                });
147            }
148        }
149            
150        $(document).on('click', '.ays-quiz-question-title-text-to-speech-icon', function(){
151            window.voiceAction = !window.voiceAction;
152            var questionText = atob($(this).attr('data-question'));
153            if ('speechSynthesis' in window) {
154                
155                var voices = quizGetVoices();
156                var voice = voices[0];
157                var language = 'en';
158                var rate = 1, pitch = 1, volume = 1;
159
160                if (voices.length !== 0) {
161                    voices.forEach((item, index) => {
162                        if (item.name == $(this).attr('data-voice')) {
163                            voice = voices[index];
164                            language = voice.lang;
165                        }
166                    });
167                }
168
169                if(window.voiceAction){
170                    listenQuestionText(questionText, voice, language, rate, pitch, volume, 'play' );
171                }
172                else{
173                    listenQuestionText(questionText, voice, language, rate, pitch, volume, 'cancel' );                        
174                }
175            }else{
176                console.log('Speech Synthesis Not Supported');
177            }
178        });
179        
180        $(document).find('.ays_next.start_button').on('click', time_limit);
181        
182        $(document).find('.ays_next.start_button').on('click', function(e){
183
184            if (typeof $(this).attr("data-enable-leave-page") !== 'undefined') {
185                $(this).attr("data-enable-leave-page",true);
186            }
187
188            if(checkQuizPassword(e, myOptions, false) === false){
189                return false;
190            }
191
192            ays_quiz_container_id = $(this).parents(".ays-quiz-container").attr("id");
193            ays_quiz_container = $('#'+ays_quiz_container_id);
194            
195            aysResetQuiz( ays_quiz_container );
196
197            ays_quiz_container.css('padding-bottom', '0px');
198            var ancnoxneriQanak = $(this).parents('.ays-questions-container').find('.ays_quizn_ancnoxneri_qanak');
199            var aysQuizReteAvg = $(this).parents('.ays-questions-container').find('.ays_quiz_rete_avg');
200            var next_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page').val();
201
202            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
203            if(isRequiredQuestion === true && !( parseInt( next_sibilings_count ) > 0 ) ){
204                ays_quiz_container.find('div[data-question-id]').each(function(){
205                    var thisStep = $(this);
206                    if(!thisStep.find('input.ays_next').hasClass('ays_display_none')){
207                        thisStep.find('input.ays_next').attr('disabled', 'disabled');
208                    }else if(!thisStep.find('i.ays_next_arrow').hasClass('ays_display_none')){
209                        thisStep.find('i.ays_next_arrow').attr('disabled', 'disabled');
210                    }
211
212                    if(!thisStep.find('input.ays_early_finish').hasClass('ays_display_none')){
213                        thisStep.find('input.ays_early_finish').attr('disabled', 'disabled');
214                    }else if(!thisStep.find('i.ays_early_finish').hasClass('ays_display_none')){
215                        thisStep.find('i.ays_early_finish').attr('disabled', 'disabled');
216                    }
217                });
218            }
219
220            if( ays_quiz_container.find('.enable_min_selection_number').length > 0 ){
221                ays_quiz_container.find('.enable_min_selection_number').each(function(){
222                    var thisStep = $(this).parents('.step');
223                    thisStep.find('input.ays_next').attr('disabled', 'disabled');
224                    thisStep.find('i.ays_next_arrow').attr('disabled', 'disabled');
225
226                    thisStep.find('input.ays_early_finish').attr('disabled', 'disabled');
227                    thisStep.find('i.ays_early_finish').attr('disabled', 'disabled');
228                });
229            }
230
231            ays_quiz_container.find('div[data-question-id][data-type="custom"]').each(function(){
232                $(this).find('i.ays_clear_answer').addClass('ays_display_none');
233                $(this).find('input.ays_clear_answer').addClass('ays_display_none');
234            });
235
236            setTimeout(function(){
237                ays_quiz_container.css('border-radius', myOptions.quiz_border_radius + 'px');
238                ays_quiz_container.find('.step').css('border-radius', myOptions.quiz_border_radius + 'px');
239            }, 400);
240            
241            aysAnimateStep(ays_quiz_container.data('questEffect'), aysQuizReteAvg);
242            aysAnimateStep(ays_quiz_container.data('questEffect'), ancno
242xneriQanak);
243            
244            if ($(this).parents('.step').next().find('.information_form').length === 0 ){
245
246                $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slideDown(500);
247                var questions_count = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').length;
248                var curent_number = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1;
249                if(questions_count <= parseInt(next_sibilings_count)){
250                    next_sibilings_count = questions_count;
251                }
252                if(parseInt(next_sibilings_count) > 0 &&
253                   ($(this).parents('.step').attr('data-question-id') || 
254                    $(this).parents('.step').next().attr('data-question-id'))){
255                    var final_width = ((parseInt(next_sibilings_count)) / questions_count * 100) + "%";
256                    if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
257                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(parseInt(next_sibilings_count)));
258                    }else{                
259                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
260                    }
261                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
262                }else{
263                    var final_width = ((curent_number+1) / questions_count * 100) + "%";
264                    if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
265                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1));
266                    }else{                
267                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
268                    }
269                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
270                }
271            }
272
273            if ( ays_quiz_container.hasClass('ays_quiz_hide_bg_on_start_page') ) {
274                ays_quiz_container.removeClass('ays_quiz_hide_bg_on_start_page');
275            }
276
277            aysQuizBullets[quizId] = createPagination($(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap'), 1);
278            aysThisQuizBullets = aysQuizBullets[quizId];
279            aysThisQuizBullets._navPage(0);
280
281        });
282
283        $(document).on('focus', '.ays-quiz-container input', function () {
284            $(window).on('keydown', function (event) {
285                var _this = $(event.target);
286                var submitFlag = true;
287                var quizLoginForm = $(event.target).parents('.ays_quiz_login_form');
288                if( quizLoginForm.length > 0 ){
289                    submitFlag = false;
290                }
291                if (event.keyCode === 13) {
292                    if( submitFlag ){
293                        return false;
294                    }
295                }
296            });
297        });
298
299        $(document).on('blur', '.ays-quiz-container input', function () {
300            $(window).off('keydown');
301        });
302        
303        $.each($(document).find('.ays_block_content'), function () {
304            if ($(document).find('.ays_block_content').length != 0) {
305                var ays_block_element = $(this).parents().eq(2);
306                ays_block_element.find('input.ays-start-date').val(GetFullDateTime());
307                ays_block_element.find('div.ays-quiz-timer').slideUp(500);
308                var timer = parseInt(ays_block_element.find('div.ays-quiz-timer').attr('data-timer'));
309                var timerInTitle = ays_block_element.find('div.ays-quiz-timer').data('showInTitle');
310                var tabTitle = document.title;
311                setTimeout(function(){
312                if (timer !== NaN) {
313                    timer += 2;
314                    if (timer !== undefined) {
315                        var countDownDate = new Date().getTime() + (timer * 1000);
316                        var x = setInterval(function () {
317                            var now = new Date().getTime();
318                            var distance = countDownDate - Math.
318ceil(now/1000)*1000;
319                            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
320                            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
321                            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
322                            var timeForShow = "";
323                            if(hours <= 0){
324                                hours = null;
325                            }else if (hours < 10) {
326                                hours = '0' + hours;
327                            }
328                            if (minutes < 10) {
329                                minutes = '0' + minutes;
330                            }
331                            if (seconds < 10) {
332                                seconds = '0' + seconds;
333                            }
334                            timeForShow =  ((hours==null)? "" : (hours + ":")) + minutes + ":" + seconds;
335                            if(distance <=1000){
336                                timeForShow = ((hours==null) ? "" : "00:") + "00:00";
337                                ays_block_element.find('div.ays-quiz-timer').html(timeForShow);
338                                if(timerInTitle){
339                                    document.title = timeForShow + " - " + tabTitle ;
340                                }
341                            }else{
342                                ays_block_element.find('div.ays-quiz-timer').html(timeForShow);
343                                if(timerInTitle){
344                                    document.title = timeForShow + " - " + tabTitle ;
345                                }
346                            }
347                            ays_block_element.find('div.ays-quiz-timer').slideDown(500);
348                            var ays_block_element_redirect_url = ays_block_element.find('.ays_redirect_url').text();
349                            if (distance <= 1) {
350                                clearInterval(x);
351                                var totalSteps = ays_block_element.find('div.step').length;
352                                var currentStep = ays_block_element.eq(2).find('div.step.active-step');
353                                var currentStepIndex = ays_block_element.eq(2).find('div.step.active-step').index();
354                                if (currentStep.hasClass('ays_thank_you_fs') === false) {
355                                    var steps = totalSteps - 3;
356                                    ays_block_element.find('div.step').each(function (index) {
357                                        if (index >= (currentStepIndex - 1) && index <= steps) {
358                                            $(this).remove();
359                                        }
360                                    });
361                                    // window.location = ays_block_element_redirect_url;
362                                    if (window.location != window.parent.location) {
363                                        parent.location = ays_block_element_redirect_url;
364                                    } else {
365                                        window.location = ays_block_element_redirect_url;
366                                    }
367                                }
368                            }
369                        }, 1000);
370                    }
371                }
372                }, 1000);
373            }
374        });
375        
376        $(document).find('button.ays_check_answer').on('click', function (e) {
377            var quizId = $(this).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
378            var thisAnswerOptions;
379            var quizContainer = $(e.target).parents('.ays-quiz-container');
380            var parentStep = $(this).parents('.step');
381            var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0);
382            var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0);
383            var questionId = $(this).parents('.step').data('questionId');
384            var questionType = $(this).parents('.step').attr('data-type');
385            var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false;
386            var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
387            var explanationTime = myOptions.explanation_time && myOptions.explanation_time != "" ? parseInt(myOptions.explanation_time) : 4;
388            var next_sibilings_count = quizContainer.find('.ays_question_count_per_page').val();
389            var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'on') ? true : false;
390            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
391
392            // Strong calculation of answers score
393            myOptions.checkbox_score_by = ( myOptions.checkbox_score_by ) ? myOptions.checkbox_score_by : 'off';
394            var checkbox_score_by = (myOptions.checkbox_score_by && myOptions.checkbox_score_by == "on") ? true : false;
395
396            // Display all questions on one page
397            myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
398            var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
399
400            var disableQuestions = false;
401            if( parseInt( next_sibilings_count ) > 0 || quiz_display_all_questions == true ){
402                disableQuestions = true;
403            }
404
405            var ans_right_wrong_icon = (myOptions.ans_right_wrong_icon && myOptions.ans_right_wrong_icon != "") ? myOptions.ans_right_wrong_icon : "default";
406
407            var correct_img_URL = "";
408            var wrong_img_URL   = "";
409            if( ans_right_wrong_icon == "default"){
410                correct_img_URL = quizLangObj.AYS_QUIZ_PUBLIC_URL + "/images/correct.png";
411                wrong_img_URL   = quizLangObj.AYS_QUIZ_PUBLIC_URL + "/images/wrong.png";
412            } else if( ans_right_wrong_icon == "none" ){
413                correct_img_URL = "";
414                wrong_img_URL   = "";
415            } else {
416                correct_img_URL = quizLangObj.AYS_QUIZ_PUBLIC_URL + "/images/correct-"+ ans_right_wrong_icon +".png";
417                wrong_img_URL   = quizLangObj.AYS_QUIZ_PUBLIC_URL + "/images/wrong-"+ ans_right_wrong_icon +".png";
418            }
419
420            var correct_img_URL_HTML = "";
421            var wrong_img_URL_HTML   = "";
422            if (correct_img_URL != "") {
423                correct_img_URL_HTML = "<img class='ays-quiz-check-button-right-wrong-icon' data-type='"+ans_right_wrong_icon+"' src='"+ correct_img_URL +"'>"
424            }
425
426            if (wrong_img_URL != "") {
427                wrong_img_URL_HTML = "<img class='ays-quiz-check-button-right-wrong-icon' data-type='"+ ans_right_wrong_icon +"' src='"+ wrong_img_URL +"'>"
428            }
429
430            thisAnswerOptions = myQuizOptions[questionId];
431
432            var fill_in_blank_flag = true;
433            if( questionType == 'fill_in_blank' ){
434                var fillInBlankUserAnswers = parentStep.find('.ays-text-input');
435                
436                var fillInBlankUserAnswersEmptyCount = 0;
437                if(fillInBlankUserAnswers.length > 0){
438                    for (var i = 0; i < fillInBlankUserAnswers.length; i++) {
439                        var current_input_val = $(fillInBlankUserAnswers[i]).val();
440                        if( current_input_val == '' ){
441                            fillInBlankUserAnswersEmptyCount++;
442                        }
443                    }
444                }
445
446                if( fillInBlankUserAnswers.length === fillInBlankUserAnswersEmptyCount ){
447                    fill_in_blank_flag = false;
448                }
449
450                if( isRequiredQuestion ){
451                    if( fillInBlankUserAnswersEmptyCount > 0 ){
452                        fill_in_blank_flag = false;
453                        ays_quiz_is_question_required( parentStep );
454                    }
455                }
456            }
457
458            var checkbox_flag = true;
459            if( questionType == 'checkbox' ){
460                var checkboxUserAnswers = parentStep.find('.ays-quiz-answers .ays-field input:checked');
461                
462                if( checkboxUserAnswers.length == 0 ){
463                    checkbox_flag = false;
464                }
465
466                var checkedMinSelCount = aysCheckMinimumCountCheckbox( parentStep, myQuizOptions );
467
468                if( !checkedMinSelCount ){
469                    checkbox_flag = false;
470                    ays_quiz_is_question_min_count( parentStep, !checkedMinSelCount );
471                }
472            }
473
474            if($(this).parent().find('.ays-text-input').val() !== "" && fill_in_blank_flag && checkbox_flag){
475                if ($(e.target).parents('form[id^="ays_finish_quiz"]').hasClass('enable_correction')) {
476                    if($(e.target).parents('.step').hasClass('not_influence_to_score')){
477                        return false;
478                    }
479                    $(this).css({
480                        animation: "bounceOut .5s",
481                    });
482                    setTimeout(function(){
483                        $(e.target).parent().find('.ays-text-input').css('width', '100%');
484                        $(e.target).css("display", "none");
485                    },480);
486                    $(e.target).parent().find('.ays-text-input').css('background-color', '#eee');
487                    $(this).parent().find('.ays-text-input').attr('disabled', 'disabled');
488                    $(this).attr('disabled', 'disabled');
489                    $(this).off('change');
490                    $(this).off('click');
491                    $(this).parents('.ays-field').addClass('ays-answered-text-input');
492
493                    var input = $(this).parent().find('.ays-text-input');
494                    var type = input.attr('type');
495
496                    var userAnsweredText = "";
497                    if( questionType != 'fill_in_blank' && questionType != 'checkbox' ){
498                        var userAnsweredText = input.val().trim();
499                    }
500
501                    // Enable case sensitive text
502                    var enable_case_sensitive_text = (thisAnswerOptions.enable_case_sensitive_text && thisAnswerOptions.enable_case_sensitive_text != "") ? thisAnswerOptions.enable_case_sensitive_text : false;
503
504                    var trueAnswered = false;
505
506                    var thisQuestionAnswer = "";
507                    var displayingQuestionAnswer = "";
508                    if( questionType != 'fill_in_blank' && questionType != 'checkbox' ){
509                        var thisQuestionAnswer = aysEscapeHtmlDecode( thisAnswerOptions.question_answer ).aysStripSlashes().toLowerCase();
510                        var displayingQuestionAnswer = thisAnswerOptions.question_answer;
511
512                        if( type == 'text' || type == 'short_text' ){
513                            if ( enable_case_sensitive_text ) {
514                                thisQuestionAnswer = aysEscapeHtmlDecode( thisAnswerOptions.question_answer ).aysStripSlashes();
515                            }
516                        }
517                    }
518
519                    if(type == 'date'){
520                        var correctDate = new Date(thisAnswerOptions.question_answer),
521                            correctDateYear = correctDate.getFullYear(),
522                            correctDateMonth = correctDate.getMonth(),
523                            correctDateDay = correctDate.getDate();
524                        var userDate = new Date(userAnsweredText),
525                            userDateYear = userDate.getFullYear(),
526                            userDateMonth = userDate.getMonth(),
527                            userDateDay = userDate.getDate();
528                        if(correctDateYear == userDateYear && correctDateMonth == userDateMonth && correctDateDay == userDateDay){
529                            trueAnswered = true;
530                        }
531                    }else if(questionType == 'fill_in_blank'){
532
533                        var fillInBlankAnswers = $(this).parents('.step').find('div.ays_quiz_question input[type="text"].ays-text-input.ays-quiz-fill-in-blank-input');
534
535                        trueAnswered = checkFillInTheBlankQuestion( fillInBlankAnswers, questionId, $(this), correct_img_URL_HTML, wrong_img_URL_HTML );
536
537                        parentStep.find('.ays_next').prop('disabled', false);
538                        parentStep.find('.ays_early_finish').prop('disabled', false);
539                        parentStep.find('.ays_previous').prop('disabled', false);
540
541                    }else if(questionType == 'checkbox'){
542
543                        var checkboxAnswers = $(this).parents('.step').find('div.ays-quiz-answers .ays-field');
544
545                        for (var i = 0; i < checkboxAnswers.length; i++) {
546                            var _checkbox_this = $(checkboxAnswers[i]).find('input[name^="ays_questions"]');
547                            _checkbox_this.addClass('ays-quiz-check-button-clicked');
548                            checkCheckboxRadioQuestion(e, _checkbox_this);
549                        }
550
551                        var userAnsweredWrongCount = parentStep.find('div.ays-quiz-answers .ays-field.checked_answer_div.wrong_div input:checked').length;
552                        var userAnsweredRightCount = parentStep.find('div.ays-quiz-answers .ays-field.checked_answer_div.correct_div input:checked').length;
553                        var correctAnswersCount    = parentStep.find('input[name="ays_answer_correct[]"][value="1"]').length;
554
555                        parentStep.find('.ays_next').prop('disabled', false);
556                        parentStep.find('.ays_early_finish').prop('disabled', false);
557                        parentStep.find('.ays_previous').prop('disabled', false);
558
559
560                        if ( checkbox_score_by ) {
561                            trueAnswered = true;
562                            if( userAnsweredWrongCount > 0 ){
563                                trueAnswered = false;
564                            } else if( correctAnswersCount != userAnsweredRightCount ){
565                                trueAnswered = false;
566                            }
567                        } else {
568                            trueAnswered = false;
569                            if( userAnsweredRightCount > userAnsweredWrongCount ){
570                                trueAnswered = true;
571                            }
572
573                            if( (correctAnswersCount - userAnsweredRightCount) > userAnsweredRightCount ){
574                                trueAnswered = false;
575                            }
576                        }
577
578                    }else if(type != 'number'){
579                        thisQuestionAnswer = thisQuestionAnswer.split('%%%');
580                        displayingQuestionAnswer = displayingQuestionAnswer.split('%%%');
581                        for(var i = 0; i < thisQuestionAnswer.length; i++){
582                            if ( enable_case_sensitive_text ) {
583                                if(userAnsweredText == thisQuestionAnswer[i].trim()){
584                                    trueAnswered = true;
585                                    break;
586                                }
587                            } else {
588                                if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i].trim()){
589                                    trueAnswered = true;
590                                    break;
591                                }
592                            }
593                        }
594                    }else{
595                        if(type == 'number'){
596                            if(userAnsweredText.toLowerCase().replace(/\.([^0]+)0+$/,".$1") == thisQuestionAnswer.trim().replace(/\.([^0]+)0+$/,".$1")){
597                                trueAnswered = true;
598                            }
599                        } else {
600                            if(userAnsweredText.toLowerCase() == thisQuestionAnswer.trim()){
601                                trueAnswered = true;
602                            }
603                        }
604                    }
605
606                    if(trueAnswered){
607                        if((right_answer_sound)){
608                            resetPlaying([right_answer_sound, wrong_answer_sound]);
609                            setTimeout(function(){
610                                right_answer_sound.play();
611                            }, 10);
612                        }
613                        $(this).parent().find('.ays-text-input').css('background-color', 'rgba(39,174,96,0.5)');
614                        $(this).parent().find('input[name="ays_answer_
614correct[]"]').val(1);
615
616                        if (correct_img_URL_HTML != "") {
617                            $(this).parent().append(correct_img_URL_HTML);
618                        }
619
620                        if(! $(this).parents('.step').hasClass('not_influence_to_score')){
621                            $(this).parents('.step').find('.right_answer_text').slideDown(250);
622                        }
623
624                        if( aysThisQuizBullets !== null ){
625                            var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
626                            var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
627                            thisBullet.attr('disabled', 'disabled');
628                            thisBullet.addClass('ays_quiz_correct_answer');
629                            if (!thisBullet.parent().hasClass('ays-quiz-questions-nav-item-last-question')) {
630                                thisBullet.parent().addClass('ays_quiz_checked_answer_div');
631                            }
632                        }
633                    }else{
634                        if((wrong_answer_sound)){
635                            resetPlaying([right_answer_sound, wrong_answer_sound]);
636                            setTimeout(function(){
637                                wrong_answer_sound.play();
638                            }, 10);
639                        }
640                        $(this).parent().find('.ays-text-input').css('background-color', 'rgba(243,134,129,0.8)');
641                        $(this).parent().find('input[name="ays_answer_correct[]"]').val(0);
642
643                        if (wrong_img_URL_HTML != "") {
644                            $(this).parent().append(wrong_img_URL_HTML);
645                        }
646
647                        if( aysThisQuizBullets !== null ){
648                            var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
649                            var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
650                            thisBullet.attr('disabled', 'disabled');
651                            thisBullet.addClass('ays_quiz_wrong_answer');
652                            if (!thisBullet.parent().hasClass('ays-quiz-questions-nav-item-last-question')) {
653                                thisBullet.parent().addClass('ays_quiz_checked_answer_div');
654                            }
655                        }
656
657                        if(showOnlyWrongAnswer === false && questionType != 'checkbox'){
658                            var rightAnswerText = '<div class="ays-text-right-answer">';
659
660                            if(type == 'date'){
661                                var correctDate = new Date(thisAnswerOptions.question_answer),
662                                    correctDateYear = correctDate.getUTCFullYear(),
663                                    correctDateMonth = (correctDate.getUTCMonth() + 1) < 10 ? "0"+(correctDate.getUTCMonth() + 1) : (correctDate.getUTCMonth() + 1),
664                                    correctDateDay = (correctDate.getUTCDate() < 10) ? "0"+correctDate.getUTCDate() : correctDate.getUTCDate();
665                                rightAnswerText += [correctDateMonth, correctDateDay, correctDateYear].join('/');
666                            }else if(type != 'number'){
667                                // rightAnswerText += thisQuestionAnswer[0];
668                                rightAnswerText += displayingQuestionAnswer[0];
669                            }else{
670                                // rightAnswerText += thisQuestionAnswer;
671                                rightAnswerText += displayingQuestionAnswer;
672                            }
673
674                            rightAnswerText += '</div>';
675                            $(this).parents('.ays-quiz-answers').append(rightAnswerText);
676                            $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500);
677                        }
678
679                        if(! $(this).parents('.step').hasClass('not_influence_to_score')){
680                            $(this).parents('.step').find('.wrong_answer_text').slideDown(250);
681                        }
682
683                        if(finishAfterWrongAnswer){
684                            $(this).parents('div[data-question-id]').find('.ays_
684next').attr('disabled', 'disabled');
685                            $(this).parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled');
686                            $(this).parents('div[data-question-id]').find('.ays_previous').attr('disabled', 'disabled');
687                            if( disableQuestions ){
688                                quizContainer.find('div[data-question-id]').css('pointer-events', 'none');
689                            }
690                            explanationTimeout = setTimeout(function(){
691                                window.aysEarlyFinishConfirmBox[ quizId ] = true;
692                                goToLastPage(e);
693                            }, explanationTime * 1000);
694                        }
695                        if(finishAfterWrongAnswer){
696                            if( aysThisQuizBullets !== null ){
697                                aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
698                                    var thisBullet = $(this);
699                                    thisBullet.attr('disabled', 'disabled');
700                                });
701                            }
702                        }
703                    }
704                    var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page";
705                    if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){
706                        if(! $(this).parents('.step').hasClass('not_influence_to_score')){
707                            $(this).parents('.step').find('.ays_questtion_explanation').slideDown(250);
708                        }
709                    }
710
711                    explanationTimeout = setTimeout(function(){
712                        if ( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
713                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
714                            if ( existsEmtpyQuestions ) {
715                                quizContainer.find('input.ays_finish').trigger('click');
716                            }
717                        }
718                    }, explanationTime * 1000);
719
720                    stopQuestionTimer(quizContainer, questionId, quizId);
721                }
722            }
723        });
724
725        $(document).find('textarea.ays_question_limit_length, input.ays_question_limit_length').on('keyup keypress', function(e) {
726            var $this = $(this);
727            var questionId = $this.attr('data-question-id');
728            var container = $this.parents('.ays-field').next('.ays_quiz_question_text_conteiner');
729            var box = container.find('.ays_quiz_question_text_message');
730            var questionTextMessage = container.find('.ays_quiz_question_text_message_span');
731
732            if (questionId !== null && questionId != '') {
733
734                // Maximum length of a text field
735                var enable_question_text_max_length = (myQuizOptions[questionId].enable_question_text_max_length && myQuizOptions[questionId].enable_question_text_max_length != "") ? myQuizOptions[questionId].enable_question_text_max_length : false;
736
737                // Length
738                var question_text_max_length = (myQuizOptions[questionId].question_text_max_length && myQuizOptions[questionId].question_text_max_length != "") ? parseInt(myQuizOptions[questionId].question_text_max_length) : '';
739
740                // Limit by
741                var question_limit_text_type = (myQuizOptions[questionId].question_limit_text_type && myQuizOptions[questionId].question_limit_text_type != "") ? myQuizOptions[questionId].question_limit_text_type : 'characters';
742
743                // Show word/character counter
744                var question_enable_text_message = (myQuizOptions[questionId].question_enable_text_message && myQuizOptions[questionId].question_enable_text_message != '') ? myQuizOptions[questionId].question_enable_text_message : false;
745
746                var remainder = '';
747                if(question_text_max_length != '' && question_text_max_length != 0){
748                    switch ( question_limit_text_type ) {
749                        case 'characters':
750                            var tval = $this.val();
751                            var tlength = tval.length;
752                            var set = question_text_max_length;
753                            var remain = parseInt(set - tlength);
754                            if (remain <= 0 && e.which !== 0 && e.charCode !== 0) {
755                                $this.val((tval).substring(0, tlength - 1));
756                            }
757                            if (e.type=="keyup") {
758                                var tval = $this.val().trim();
759                                if(tval.length > 0 && tval != null){
760                                    var wordsLength = this.value.split('').length;
761                                    if (wordsLength > question_text_max_length) {
762                                        var trimmed = tval.split('', question_text_max_length).join("");
763                                        $this.val(trimmed);
764                                    }
765                                }
766                            }
767                            remainder = remain;
768                            break;
769                        case 'words':
770                            if (e.type=="keyup") {
771                                var tval = $this.val().trim();
772                                if(tval.length > 0 && tval != null){
773                                    var wordsLength = this.value.match(/\S+/g).length;
774                                    if (wordsLength > question_text_max_length) {
775                                        var trimmed = tval.split(/\s+/, question_text_max_length).join(" ");
776                                        $this.val(trimmed + " ");
777                                    }
778                                    remainder = question_text_max_length - wordsLength;
779                                }
780                            }
781                            break;
782                        default:
783                            break;
784                    }
785                    if (e.type=="keyup") {
786                        if ( question_enable_text_message ) {
787                            if(question_text_max_length != '' && question_text_max_length != 0){
788                                if (remainder <= 0) {
789                                    remainder = 0;
790                                    if (! box.hasClass('ays_quiz_question_text_error_message') ) {
791                                        box.addClass('ays_quiz_question_text_error_message')
792                                    }
793                                }else{
794                                    if ( box.hasClass('ays_quiz_question_text_error_message') ) {
795                                        box.removeClass('ays_quiz_question_text_error_message')
796                                    }
797                                }
798                                if (tval.length == 0 || tval == null) {
799                                    if ( box.hasClass('ays_quiz_question_text_error_message') ) {
800                                        box.removeClass('ays_quiz_question_text_error_message')
801                                    }
802                                    remainder = question_text_max_length;
803                                }
804
805                                questionTextMessage.html( remainder );
806                            }
807                        }
808                    }
809                }
810            }
811        });
812
813        $(document).on('click', '.enable_max_selection_number input[type="checkbox"]', function(e) {
814            var $this = $(this);
815
816            var parent = $this.parents('.step');
817            var questionId = parent.attr('data-question-id');
818            questionId = parseInt( questionId );
819
820            var checkedCount = parent.find('.ays-field input[type="checkbox"]:checked').length;
821
822            if (questionId !== null && questionId != '' && typeof myQuizOptions[questionId] != 'undefined') {
823
824                // Maximum length of a text field
825                var enable_max_selection_number = (myQuizOptions[questionId].enable_max_selection_number && myQuizOptions[questionId].enable_max_selection_number != "") ? myQuizOptions[questionId].enable_max_selection_number : false;
826
827                // Length
828                var max_selection_number = (myQuizOptions[questionId].max_selection_number && myQuizOptions[questionId].max_selection_number != "") ? parseInt(myQuizOptions[questionId].max_selection_number) : '';
829
830                if( enable_max_selection_number === true && max_selection_number != '' ){
831
832                    if( max_selection_number < checkedCount ){
833                        return false;
834                    }
835                }
836            }
837
838        });
839
840        $(document).on('click', '.enable_min_selection_number input[type="checkbox"]', function(e) {
841            var $this = $(this);
842            var this_current_fs = $this.parents('.step[data-question-id]');
843            var enableArrows = $this.parents(".ays-questions-container").find(".ays_qm_enable_arrows").val();
844            var questions = $(this).parents('form.ays-quiz-form').find('.step[data-question-id]');
845            var next_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page').val();
846            var current_fs_indexes = [];
847
848            var thisIndex = 0;
849            for( var j = 0; j < Math.floor( questions.length / parseInt( next_sibilings_count ) ); j++ ){
850                thisIndex += parseInt( next_sibilings_count );
851                current_fs_indexes.push( thisIndex - 1 );
852            }
853
854            var thisStepIndex = 0;
855            var thisQuestionStepIndex = questions.index( $this.parents('.step[data-question-id]') );
856            for( var k = 0; k < current_fs_indexes.length; k++ ){
857                if( thisQuestionStepIndex <= current_fs_indexes[k] ){
858                    thisStepIndex = current_fs_indexes[k];
859                    break;
860                }
861            }
862
863            if( thisStepIndex == 0 ){
864                thisStepIndex = questions.length - 1;
865            }
866
867            var current_fs_index = questions.index( questions.eq( thisStepIndex ) );
868
869            // Display all questions on one page
870            myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
871            var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
872
873            if ( quiz_display_all_questions ) {
874                next_sibilings_count = questions.length;
875            }
876
877
878            var buttonsDiv = $(this).parents('form.ays-quiz-form').find('.step[data-question-id]').eq( thisStepIndex ).find('.ays_buttons_div');
879            if($(this).parents('.step').attr('data-question-id')){
880                if( parseInt( next_sibilings_count ) > 0 && ( $(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id') ) ){
881                    var sliceStart = current_fs_index - parseInt( next_sibilings_count ) < 0 ? 0 : current_fs_index - parseInt( next_sibilings_count ) + 1;
882                    this_current_fs = questions.slice( sliceStart, current_fs_index + 1 );
883                }else{
884                    this_current_fs = $(this).parents('.step[data-question-id]');
885                    buttonsDiv = this_current_fs.find('.ays_buttons_div');
886                }
887            }else{
888                this_current_fs = $(this).parents('.step[data-question-id]');
889                buttonsDiv = this_current_fs.find('.ays_buttons_div');
890            }
891
892            this_current_fs.each(function(){
893                var checkedMinSelCount = aysCheckMinimumCountCheckbox( $(this), myQuizOptions );
894
895                // if( ays_quiz_is_question_min_count( $(this), !checkedMinSelCount ) === true ){
896                    if( checkedMinSelCount == true ){
897                        if(enableArrows){
898                            buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled');
899                            buttonsDiv.find('i.ays_next_arrow').prop('disabled', false);
900                            buttonsDiv.find('i.ays_early_finish').prop('disabled', false);
901                        }else{
902                            buttonsDiv.find('input.ays_next').removeAttr('disabled');
903                            buttonsDiv.find('input.ays_next').prop('disabled', false);
904                            buttonsDiv.find('input.ays_early_finish').prop('disabled', false);
905                        }
906                    }else{
907                        if(enableArrows){
908                            buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
909                            buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
910                            buttonsDiv.find('i.ays_early_finish').prop('disabled', true);
911                        }else{
912                            buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
913                            buttonsDiv.find('input.ays_next').prop('disabled', true);
914                            buttonsDiv.find('input.ays_early_finish').prop('disabled', true);
915                        }
916                    }
917                // }else{
918                //     if(enableArrows){
919                //         buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
920                //         buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
921                //         buttonsDiv.find('i.ays_early_finish').prop('disabled', true);
922                //     }else{
923                //         buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
924                //         buttonsDiv.find('input.ays_next').prop('disabled', true);
925                //         buttonsDiv.find('input.ays_early_finish').prop('disabled', true);
926                //         return false;
927                //     }
928                // }
929            });
930        });
931
932        // on('keyup keypress') old event
933        $(document).find('input.ays_question_number_limit_length').on('focusout', function(e) {
934            var $this = $(this);
935            var questionId = $this.parents('.step[data-question-id]').attr('data-question-id');
936            var parent = $this.parents('.ays-abs-fs');
937
938            if (questionId !== null && questionId != '') {
939                var questionOptions = myQuizOptions[questionId];
940
941                // Maximum length of a number field
942                var enable_question_number_max_length = (questionOptions.enable_question_number_max_length && questionOptions.enable_question_number_max_length != "") ? questionOptions.enable_question_number_max_length : false;
943
944                // Length
945                var question_number_max_length = (typeof questionOptions.question_number_max_length != 'undefined' && questionOptions.question_number_max_length !== "") ? parseInt(questionOptions.question_number_max_length) : '';
946
947                // Minimum length of a number field
948                var enable_question_number_min_length = (questionOptions.enable_question_number_min_length && questionOptions.enable_question_number_min_length != "") ? questionOptions.enable_question_number_min_length : false;
949
950                // Length
951                var question_number_min_length = (typeof questionOptions.question_number_min_length != 'undefined' && questionOptions.question_number_min_length !== "") ? parseInt(questionOptions.question_number_min_length) : '';
952
953                // Show error message
954                var enable_question_number_error_message = (questionOptions.enable_question_number_error_message && questionOptions.enable_question_number_error_message != "") ? questionOptions.enable_question_number_error_message : false;
955
956                // Message
957                var question_number_error_message = (questionOptions.question_number_error_message && questionOptions.question_number_error_message != "") ? questionOptions.question_number_error_message : '';
958
959                if ( enable_question_number_max_length ) {
960                    if(question_number_max_length !== ''){
961                        var tval = $this.val().trim();
962                        var inputVal = parseInt( tval );
963
964                        if( ! isNaN(inputVal) ){
965                            if ( inputVal > question_number_max_length ) {
966                                $this.val(question_number_max_length);
967                            }
968
969                            if (e.type=="keyup") {
970                                if ( inputVal > question_number_max_length ) {
971                                    $this.val(question_number_max_length);
972                                }
973                            }
974                        }
975                    }
976                }
977
978                if ( enable_question_number_min_length ) {
979                    if(question_number_min_length !== ''){
980                        var tval = $this.val().trim();
981                        var inputVal = parseInt( tval );
982                        if( ! isNaN(inputVal) ){
983                            if ( inputVal < question_number_min_length ) {
984                                $this.val(question_number_min_length);
985                            }
986
987                            if (e.type=="keyup") {
988                                if ( inputVal < question_number_min_length ) {
989                                    $this.val(question_number_min_length);
990                                }
991                            }
992                        }
993                    }
994                }
995
996                if ( enable_question_number_error_message ) {
997                    if ( question_number_error_message != "" ) {
998                        var tval = $this.val().trim();
999                        var inputVal = tval;
1000
1001                        var errorMessageBox = parent.find('.ays-quiz-number-error-message');
1002
1003                        if ( tval != "" ) {
1004
1005                            if ( isNaN( +inputVal ) ) {
1006                                if ( errorMessageBox.hasClass('ays_display_none') ) {
1007                                    errorMessageBox.removeClass('ays_display_none');
1008                                }
1009                            } else if ( tval.indexOf("e") > -1 ) {
1010                                if ( errorMessageBox.hasClass('ays_display_none') ) {
1011                                    errorMessageBox.removeClass('ays_display_none');
1012                                }
1013                            } else if ( tval.slice(-1) == "e" ) {
1014                                if ( errorMessageBox.hasClass('ays_display_none') ) {
1015                                    errorMessageBox.removeClass('ays_display_none');
1016                                }
1017                            } else {
1018                                if ( ! errorMessageBox.hasClass('ays_display_none') ) {
1019                                    errorMessageBox.addClass('ays_display_none');
1020                                }
1021                            }
1022                        } else {
1023                            if ( ! errorMessageBox.hasClass('ays_display_none') ) {
1024                                errorMessageBox.addClass('ays_display_none');
1025                            }
1026                        }
1027                    }
1028                }
1029            }
1030        });
1031
1032        $(document).on('change', 'input[name^="ays_questions"]', function (e) {
1033            var _this = $(this);
1034
1035            checkCheckboxRadioQuestion(e, _this);
1036
1037        });
1038
1039        $(document).on('change', 'textarea[name^="ays_questions"], input[type="text"][name^="ays_questions"], input[type="number"][name^="ays_questions"], input[type="date"][name^="ays_questions"]', function (e) {
1040            if( $(e.target).val().length > 0 ){
1041                if( aysThisQuizBullets !== null ){
1042                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1043                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1044                    thisBullet.parents('.ays-quiz-questions-nav-item').addClass('ays-quiz-questions-nav-item-answered');
1045                    $(e.target).parents('div[data-question-id]').removeClass('ays-has-error');
1046                    thisBullet.removeClass('ays-has-error');
1047                }
1048            }else{
1049                if( aysThisQuizBullets !== null ){
1050                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1051                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1052                    thisBullet.parents('.ays-quiz-questions-nav-item').removeClass('ays-quiz-questions-nav-item-answered');
1053                }
1054            }
1055        });
1056
1057        $(document).on('input', 'textarea[name^="ays_questions"], input[name^="ays_questions"]', function (e) {
1058
1059            var _this = $(this);
1060            var parentStep = _this.parents('.step');
1061            var questionType = parentStep.attr('data-type');
1062
1063            if( $(e.target).val().length > 0 ){
1064                if( aysThisQuizBullets !== null ){
1065                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1066                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1067                    thisBullet.parents('.ays-quiz-questions-nav-item').addClass('ays-quiz-questions-nav-item-answered');
1068                    $(e.target).parents('div[data-question-id]').removeClass('ays-has-error');
1069                    thisBullet.removeClass('ays-has-error');
1070                }
1071            }else{
1072                if( aysThisQuizBullets !== null ){
1073                    var thisQuestionID = $(e.target).parents('div[data-question-id]').data('questionId');
1074                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
1075                    thisBullet.parents('.ays-quiz-questions-nav-item').removeClass('ays-quiz-questions-nav-item-answered');
1076                }
1077            }
1078
1079            if(typeof myOptions != 'undefined'){
1080                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
1081                if(isRequiredQuestion === true){
1082                    if( questionType === 'fill_in_blank' ){
1083                        var fill_in_blank_answers = parentStep.find('.ays-quiz-fill-in-blank-input');
1084
1085                        var fill_in_blank_flag = true;
1086                        if(fill_in_blank_answers.length > 0){
1087                            for (var i = 0; i < fill_in_blank_answers.length; i++) {
1088                                var current_input_val = $(fill_in_blank_answers[i]).val();
1089                                if( current_input_val == '' ){
1090                                    fill_in_blank_flag = false;
1091                                    break;
1092                                }
1093                            }
1094                        }
1095
1096                        if( fill_in_blank_flag ){
1097                            if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
1098                                $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
1099                                $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
1100                            }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1101                                $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
1102                                $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
1103                            }
1104                        }else{
1105                            if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
1106                                $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true);
1107                                $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true);
1108                            }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1109                                $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true);
1110                                $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true);
1111                            }
1112                        }
1113                    } else {
1114                        if($(e.target).attr('type') === 'text' ||
1115                           $(e.target).attr('type') === 'number' ||
1116                           $(e.target).attr('type') === 'date'){
1117                            if($(e.target).val() != ''){
1118                                if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
1119                                    $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
1120                                    $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
1121                                }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1122                                    $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
1123                                    $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
1124                                }
1125                            }else{
1126                                if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
1127                                    $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true);
1128                                    $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true);
1129                                }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
1130                                    $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true);
1131                                    $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true);
1132                                }
1133                            }
1134                        }
1135                    }
1136                }
1137            }
1138        });
1139
1140        $(document).on('input', '.information_form input[name="ays_user_name"]', function(){
1141            if ($(this).attr('type') !== 'hidden') {
1142                $(this).removeClass('ays_red_border');
1143                $(this).removeClass('ays_green_border');
1144                if($(this).val() != ''){
1145                    $(this).addClass('ays_green_border');
1146                } else {
1147                    $(this).addClass('ays_red_border');
1148                }
1149            }
1150        });
1151
1152        $(document).on('input', '.information_form input[name="ays_user_phone"]', function(){
1153            if ($(this).attr('type') !== 'hidden') {
1154                $(this).removeClass('ays_red_border');
1155                $(this).removeClass('ays_green_border');
1156                if($(this).val() != ''){
1157                    if (!validatePhoneNumber($(this).get(0))) {
1158                        $(this).addClass('ays_red_border');
1159                    }else{
1160                        $(this).addClass('ays_green_border');
1161                    }
1162                }
1163            }
1164        });
1165        
1166        $(document).on('input', 'input.ays_quiz_password', function(e){
1167            var $this = $(this);
1168            var startButton = $this.parents('.ays-quiz-container').find('input.start_button');
1169            if($this.val() != ''){
1170                startButton.removeAttr('disabled');
1171            }else{
1172                startButton.attr('disabled', 'disabled');
1173            }
1174        });
1175
1176        $(document).on('click', '.ays-quiz-password-toggle', function(e){
1177            var $this  = $(this);
1178
1179            var parent = $this.parents('.ays-quiz-password-toggle-visibility-box');
1180            var passwordInput = parent.find('.ays_quiz_password');
1181
1182            var visibilityOn  = parent.find('.ays-quiz-password-toggle-visibility');
1183            var visibilityOff = parent.find('.ays-quiz-password-toggle-visibility-off');
1184
1185            if( $this.hasClass('ays-quiz-password-toggle-visibility-off') ) {
1186                passwordInput.attr('type', 'text');
1187
1188                if ( visibilityOn.hasClass('ays_display_none') ) {
1189                    visibilityOn.removeClass('ays_display_none');
1190                }
1191
1192                if ( ! visibilityOff.hasClass('ays_display_none') ) {
1193                    visibilityOff.addClass('ays_display_none');
1194                }
1195
1196            } else if( $this.hasClass('ays-quiz-password-toggle-visibility') ) {
1197                passwordInput.attr('type', 'password');
1198
1199                if ( ! visibilityOn.hasClass('ays_display_none') ) {
1200                    visibilityOn.addClass('ays_display_none');
1201                }
1202
1203                if ( visibilityOff.hasClass('ays_display_none') ) {
1204                    visibilityOff.removeClass('ays_display_none');
1205                }
1206            }
1207        });
1208
1209        setTimeout(function(){
1210            $(document).find('input.ays_quiz_password').val('');
1211        }, 500);
1212
1213        $(document).on('input', '.information_form input[name="ays_user_email"], .information_form input[type="email"]', function(){
1214            if ($(this).attr('type') !== 'hidden') {
1215                $(this).removeClass('ays_red_border');
1216                $(this).removeClass('ays_green_border');
1217                if($(this).val() != ''){
1218                    if (!(emailValivatePattern.test($(this).val()))) {
1219                        $(this).addClass('ays_red_border');
1220                    }else{
1221                        $(this).addClass('ays_green_border');
1222                    }
1223                }
1224            }
1225        });
1226
1227        $(document).find('.ays-text-field .ays-text-input').each(function(ev){
1228            $(this).on('keydown', function(e){
1229                myOptions.enable_enter_key = !( myOptions.enable_enter_key ) ? "on" : myOptions.enable_enter_key;
1230                var enableEnterKey = (myOptions.enable_enter_key && myOptions.enable_enter_key == "on") ? true : false;
1231                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
1232                var isKeyboardNavigation = (myOptions.quiz_enable_keyboard_navigation && myOptions.quiz_enable_keyboard_navigation == "on") ? true : false;
1233                if(enableEnterKey || isKeyboardNavigation){
1234                    if (e.keyCode === 13 && !e.shiftKey) {
1235                        if(animating){
1236                            return false;
1237                        }
1238                        if(isRequiredQuestion === true){
1239                            if($(this).val() == ''){
1240                                return false;
1241                            }
1242                        }
1243                        if($(this).parents('.step').find('input.ays_finish.action-button').length > 0){
1244                            $(this).parents('.step').find('input.ays_finish.action-button').trigger('click');
1245                        }else{
1246                            $(this).parents('.step').find('input.ays_next.action-button').trigger('click');
1247                        }
1248                        $(this).trigger('blur');
1249                        return false;
1250                    }
1251                }
1252            });
1253        });
1254
1255        $(document).find('.ays_next').on('click', function(e){
1256            e.preventDefault();
1257            var quizId = $(this).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
1258
1259            if(checkQuizPassword(e, myOptions, true) === false){
1260                return false;
1261            }
1262
1263            if ( typeof window.aysSeeResultConfirmBox[ quizId ] != 'undefined' && window.aysSeeResultConfirmBox[ quizId ] ) {
1264                window.aysSeeResultConfirmBox[ quizId ] = false;
1265                return false;
1266            }
1267
1268            if(typeof explanationTimeout != 'undefined'){
1269                clearTimeout(explanationTimeout);
1270            }
1271
1272            ays_quiz_container = $(this).parents(".ays-quiz-container");
1273            if (!($(this).hasClass('start_button'))) {
1274                if ($(this).parents('.step').find('input[required]').length !== 0 || 
1275                    $(this).parents('.step').find('select.ays_quiz_form_input[required]').length !== 0) {
1276                    var empty_inputs = 0;
1277                    var required_inputs = $(this).parents('.step').find('input[required]');
1278                    $(this).parents('.step').find('.ays_red_border').removeClass('ays_red_border');
1279                    $(this).parents('.step').find('.ays_green_border').removeClass('ays_green_border');
1280                    for (var i = 0; i < required_inputs.length; i++) {
1281                        switch(required_inputs.eq(i).attr('type')){
1282                            case "checkbox": {
1283                                if(required_inputs.eq(i).prop('checked') === false){
1284                                    required_inputs.eq(i).addClass('ays_red_border');
1285                                    required_inputs.eq(i).addClass('shake');
1286                                    empty_inputs++;
1287                                }else{
1288                                    required_inputs.eq(i).addClass('ays_green_border');
1289                                }
1290                                break;
1291                            }
1292                            case "email": {
1293                                if (!(emailValivatePattern.test(required_inputs.eq(i).val()))) {
1294                                    required_inputs.eq(i).addClass('ays_red_border');
1295                                    required_inputs.eq(i).addClass('shake');
1296                                    empty_inputs++;
1297                                }else{
1298                                    required_inputs.eq(i).addClass('ays_green_border');
1299                                }
1300                                break;
1301                            }
1302                            case "tel": {
1303                                if (!validatePhoneNumber(required_inputs.eq(i).get(0))) {
1304                                    required_inputs.eq(i).addClass('ays_red_border');
1305                                    required_inputs.eq(i).addClass('shake');
1306                                    empty_inputs++;
1307                                }else{
1308                                    required_inputs.eq(i).addClass('ays_green_border');
1309                                }
1310                                break;
1311                            }
1312                            case "file": {
1313                                var fileParentDiv = required_inputs.eq(i).parents('.ays-quiz-upload-type-main');
1314                                var hiddenInputFileValue = fileParentDiv.find('.ays-quiz-upload-ready-url-link').val();
1315                                if (! hiddenInputFileValue ) {
1316                                    fileParentDiv.addClass('ays_red_border');
1317                                    fileParentDiv.addClass('shake');
1318                                    empty_inputs++;
1319                                }else{
1320                                    fileParentDiv.addClass('ays_green_border');
1321                                }
1322                                break;
1323                            }
1324                            default:{
1325                                if (required_inputs.eq(i).val().trim() === '' &&
1326                                    required_inputs.eq(i).attr('type') !== 'hidden') {
1327                                    required_inputs.eq(i).addClass('ays_red_border');
1328                                    required_inputs.eq(i).addClass('shake');
1329                                    empty_inputs++;
1330                                }else{
1331                                    required_inputs.eq(i).addClass('ays_green_border');
1332                                }
1333                                break;
1334                            }
1335                        }
1336                    }
1337                    var empty_inputs2 = 0;
1338                    var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]');
1339                    var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]');
1340                    var selectAttr = $(this).parents('.step').find('select.ays_quiz_form_input[required]');
1341                    if(phoneInput.val() != ''){
1342                        phoneInput.removeClass('ays_red_border');
1343                        phoneInput.removeClass('ays_green_border');
1344                        if (!validatePhoneNumber(phoneInput.get(0))) {
1345                            if (phoneInput.attr('type') !== 'hidden') {
1346                                phoneInput.addClass('ays_red_border');
1347                                phoneInput.addClass('shake');
1348                                empty_inputs2++;
1349                            }
1350                        }else{
1351                            phoneInput.addClass('ays_green_border');
1352                        }
1353                    }
1354                    if(emailInput.val() != ''){
1355                        emailInput.removeClass('ays_red_border');
1356                        emailInput.removeClass('ays_green_border');
1357                        if (!(emailValivatePattern.test(emailInput.val()))) {
1358                            if (emailInput.attr('type') !== 'hidden') {
1359                                emailInput.addClass('ays_red_border');
1360                                emailInput.addClass('shake');
1361                                empty_inputs++;
1362                            }
1363                        }else{
1364                            emailInput.addClass('ays_green_border');
1365                        }
1366                    }
1367
1368                    for (var i = 0; i < selectAttr.length; i++) {
1369                        if(selectAttr.eq(i).val() == ''){
1370                            selectAttr.eq(i).removeClass('ays_red_border');
1371                            selectAttr.eq(i).removeClass('ays_green_border');
1372
1373                            selectAttr.eq(i).addClass('ays_red_border');
1374                            selectAttr.eq(i).addClass('shake');
1375                            empty_inputs++;
1376                        }else{
1377                            selectAttr.eq(i).removeClass('ays_red_border');
1378                        }
1379                    }
1380                    var errorFields = $(this).parents('.step').find('.ays_red_border');
1381                    if (empty_inputs2 !== 0 || empty_inputs !== 0) {
1382                        setTimeout(function(){
1383                            errorFields.each(function(){
1384                                $(this).removeClass('shake');
1385                            });
1386                        }, 500);
1387                        setTimeout(function(){
1388                            required_inputs.each(function(){
1389                                $(this).removeClass('shake');
1390                            });
1391                        }, 500);
1392                        return false;
1393                    }else{
1394                        $(this).addClass('ays_start_allow');
1395                    }
1396                }else{
1397                    if ($(this).parents('.step').find('.information_form').length !== 0 ){
1398                        var empty_inputs = 0;
1399                        var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]');
1400                        var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]');
1401                        var emailInputs = $(this).parents('.step').find('input[type="email"]');
1402                        if(phoneInput.val() != ''){
1403                            phoneInput.removeClass('ays_red_border');
1404                            phoneInput.removeClass('ays_green_border');
1405                            if (!validatePhoneNumber(phoneInput.get(0))) {
1406                                if (phoneInput.attr('type') !== 'hidden') {
1407                                    phoneInput.addClass('ays_red_border');
1408                                    phoneInput.addClass('shake');
1409                                    empty_inputs++;
1410                                }
1411                            }else{
1412                                phoneInput.addClass('ays_green_border');
1413                            }
1414                        }
1415                        if(emailInput.val() != ''){
1416                            emailInput.removeClass('ays_red_border');
1417                            emailInput.removeClass('ays_green_border');
1418                            if (!(emailValivatePattern.test(emailInput.val()))) {
1419                                if (emailInput.attr('type') !== 'hidden') {
1420                                    emailInput.addClass('ays_red_border');
1421                                    emailInput.addClass('shake');
1422                                    empty_inputs++;
1423                                }
1424                            }else{
1425                                emailInput.addClass('ays_green_border');
1426                            }
1427                        }
1428                        emailInputs.each(function(){
1429                            var thisEmailInput = $(this);
1430                            if(thisEmailInput.val() != ''){
1431                                thisEmailInput.removeClass('ays_red_border');
1432                                thisEmailInput.removeClass('ays_green_border');
1433                                if (!(emailValivatePattern.test(thisEmailInput.val()))) {
1434                                    thisEmailInput.addClass('ays_red_border');
1435                                    thisEmailInput.addClass('shake');
1436                                    empty_inputs++;
1437                                }else{
1438                                    thisEmailInput.addClass('ays_green_border');
1439                                }
1440                            }
1441                        });
1442                        var errorFields = $(this).parents('.step').find('.ays_red_border');
1443                        if (empty_inputs !== 0) {
1444                            setTimeout(function(){
1445                                errorFields.each(function(){
1446                                    $(this).removeClass('shake');
1447                                });
1448                            }, 500);
1449                            return false;
1450                        }
1451                        $(this).addClass('ays_start_allow');
1452                    }
1453                }
1454            }
1455            
1456            if (animating) return false;
1457            animating = true;
1458            current_fs = $(this).parents('.step');
1459            next_fs = $(this).parents('.step').next();
1460
1461            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
1462            var enableNavigationBar = (myOptions.enable_navigation_bar && myOptions.enable_navigation_bar == "on") ? true : false;
1463            var quizDisableInputFocusing = (myOptions.quiz_disable_input_focusing && myOptions.quiz_disable_input_focusing == "on") ? true : false;
1464            var timerMainContainer = ays_quiz_container.find('.ays_quiz_timer_container');
1465            var timerType = myOptions.quiz_timer_type ? myOptions.quiz_timer_type : 'quiz_timer';
1466
1467            if( current_fs.find('.information_form').length === 0 && !($(this).hasClass('ays_finish')) && !($(this).hasClass('start_button')) ) {
1468                if (myOptions.enable_timer && myOptions.enable_timer === 'on') {
1469                    if (myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'question_timer') {
1470                        if (window.aysQuizQuestionTimers && window.aysQuizQuestionTimers[quizId]) {
1471                            if (myOptions.enable_navigation_bar && myOptions.enable_navigation_bar === 'on') {
1472                                if (myOptions.make_questions_required && myOptions.make_questions_required === "on") {
1473                                    var qid = checkQuestionTimer(ays_quiz_container, quizId);
1474                                    if (qid === false) {
1475                                        for (var questionID in window.aysQuizQuestionTimers[quizId]) {
1476                                            stopQuestionTimer(ays_quiz_container, questionID, quizId);
1477                                        }
1478                                        timerMainContainer.addClass('ays-quiz-timer-end-for-required')
1479                                    }
1480                                }
1481                            }
1482                        }
1483                    }
1484                }
1485            }
1486
1487            if ( typeof window.aysEarlyFinishConfirmBox[ quizId ] != 'undefined' && ! window.aysEarlyFinishConfirmBox[ quizId ] ) {
1488                if( ! timerMainContainer.hasClass('ays-quiz-timer-end-for-required') ){
1489                    if(isRequiredQuestion === true){
1490                        if(next_fs.find('.information_form').length === 0){
1491                            if ( $(this).hasClass("ays_finish") ) {
1492                                if ( enableNavigationBar ) {
1493                                    ays_quiz_is_question_required( ays_quiz_container.find('.step') );
1494                                    if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
1495                                        return false;
1496                                    }
1497                                }
1498                            }
1499                        } else {
1500                            var questions_count = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').length;
1501                            var curent_number = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))+1;
1502                            var questionCountPerPage = myOptions.question_count_per_page && myOptions.question_count_per_page === 'on' ? true : false;
1503                            if(questions_count === curent_number){
1504                                if ( enableNavigationBar ) {
1505
1506                                    ays_quiz_is_question_required( ays_quiz_container.find('.step') );
1507                                    if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
1508                                        return false;
1509                                    }
1510                                } else if( questionCountPerPage ){
1511                                    ays_quiz_is_question_required( ays_quiz_container.find('.step') );
1512                                    if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
1513                                        return false;
1514                                    }
1515                                }
1516                            }
1517                        }
1518                    }
1519                }
1520            }
1521
1522            if (!($(this).hasClass('start_button')) && $(this).parents('.step').find('.information_form').length === 0  && ! window.aysEarlyFinishConfirmBox[ quizId ]) {
1523                if( $(this).parents('form.ays-quiz-form').find('div[data-question-id]').index($(this).parents('.step'))+1 === $(this).parents('form.ays-quiz-form').find('div[data-question-id]').length ){
1524                    var minSelHasError = 0;
1525                    var minSelQuestions;
1526                    var checkbox_current_fs = $(this).parents('form.ays-quiz-form').find('.step[data-type="checkbox"]');
1527                    var buttonsDiv2 = $(this).parents('.step').find('.ays_buttons_div');
1528                    // var last_fs = $(this).parents('form').find('.step[data-question-id]').last();
1529                   // if(($(this).hasClass('ays_finish')) == false){
1530                   //     minSelQuestions = next_siblings;
1531                   // }else{
1532                        minSelQuestions = checkbox_current_fs;
1533                   // }
1534                    var checkboxMinCountAndNavigationFlag = false;
1535                    for( var k = 0; k < minSelQuestions.length; k++ ){
1536                        if( $( minSelQuestions[k] ).find('.enable_min_selection_number').length > 0 ){
1537                            var checkedMinSelCount = aysCheckMinimumCountCheckbox( $( minSelQuestions[k] ), myQuizOptions );
1538                            if( ays_quiz_is_question_min_count( $( minSelQuestions[k] ), !checkedMinSelCount ) === true ){
1539                                if( checkedMinSelCount == true ){
1540                                    if(enableArrows){
1541                                        buttonsDiv2.find('i.ays_next_arrow').removeAttr('disabled');
1542                                        buttonsDiv2.find('i.ays_next_arrow').prop('disabled', false);
1543                                    }else{
1544                                        buttonsDiv2.find('input.ays_next').removeAttr('disabled');
1545                                        buttonsDiv2.find('input.ays_next').prop('disabled', false);
1546                                    }
1547                                }else{
1548                                    if(enableArrows){
1549                                        // buttonsDiv2.find('i.ays_next_arrow').attr('disabled', 'disabled');
1550                                        buttonsDiv2.find('i.ays_next_arrow').prop('disabled', false);
1551                                        buttonsDiv2.find('i.ays_next_arrow').removeClass('ays_display_none');
1552                                    }else{
1553                                        // buttonsDiv2.find('input.ays_next').attr('disabled', 'disabled');
1554                                        buttonsDiv2.find('input.ays_next').prop('disabled', false);
1555                                        buttonsDiv2.find('input.ays_next').removeClass('ays_display_none');
1556                                    }
1557                                    minSelHasError++;
1558                                    if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {  
1559                                        if( myOptions.quiz_timer_type && ( myOptions.quiz_timer_type === 'question_timer' || myOptions.quiz_timer_type === 'quiz_timer') ){
1560
1561                                            var c_qid = checkChecboxQuestionTimerForSubmitQuiz(ays_quiz_container, quizId, $( minSelQuestions[k] ));
1562                                            if (c_qid !== false) {
1563                                                checkboxMinCountAndNavigationFlag = true;
1564                                                // ays_quiz_container.find('.ays_questions_nav_question[data-id="' + c_qid + '"]').trigger('click');
1565                                            }else if( c_qid === false && minSelHasError > 0 ) {
1566                                                checkboxMinCountAndNavigationFlag = true;
1567                                            }
1568                                        }
1569                                    }
1570                                }
1571                            }else{
1572                                if(enableArrows){
1573                                    // buttonsDiv2.find('i.ays_next_arrow').attr('disabled', 'disabled');
1574                                    buttonsDiv2.find('i.ays_next_arrow').prop('disabled', false);
1575                                    buttonsDiv2.find('i.ays_next_arrow').removeClass('ays_display_none');
1576                                }else{
1577                                    // buttonsDiv2.find('input.ays_next').attr('disabled', 'disabled');
1578                                    buttonsDiv2.find('input.ays_next').prop('disabled', false);
1579                                    buttonsDiv2.find('input.ays_next').removeClass('ays_display_none');
1580                                }
1581                                minSelHasError++;
1582                                if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
1583                                    if( myOptions.quiz_timer_type && ( myOptions.quiz_timer_type === 'question_timer' || myOptions.quiz_timer_type === 'quiz_timer') ){
1584
1585                                        var c_qid = checkChecboxQuestionTimerForSubmitQuiz(ays_quiz_container, quizId, $( minSelQuestions[k] ));
1586                                        if (c_qid !== false) {
1587                                            checkboxMinCountAndNavigationFlag = true;
1588                                            // ays_quiz_container.find('.ays_questions_nav_question[data-id="' + c_qid + '"]').trigger('click');
1589                                        }else if( c_qid === false && minSelHasError > 0 ) {
1590                                            checkboxMinCountAndNavigationFlag = true;
1591                                        }
1592                                    }
1593                                }
1594                            }
1595                        }
1596                    }
1597
1598                    if( minSelHasError > 0 ){
1599                        return false;
1600                    }
1601                    else if( checkboxMinCountAndNavigationFlag ){
1602                        return false;
1603                    }
1604                }
1605                
1606            }
1607
1608            if( current_fs.find('.information_form').length != 0 && !($(this).hasClass('ays_finish'))){
1609                $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slideDown(500);
1610            }
1611
1612            if( next_fs.find('.information_form').length != 0 ){
1613                stopQuestionTimer( ays_quiz_container, current_fs.data('questionId'), quizId );
1614                $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slide
1614Up(500);
1615                timerMainContainer.slideUp(500);
1616            }
1617
1618            var questions_count = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').length;
1619            var curent_number = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1;
1620            var next_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page').val();
1621
1622            var isQuestionPerPageCustom = (myOptions.question_count_per_page_type && myOptions.question_count_per_page_type == "custom") ? true : false;
1623            var customPerPageValue = (myOptions.question_count_per_page_custom_order && myOptions.question_count_per_page_custom_order != "") ? myOptions.question_count_per_page_custom_order : "";
1624            var customPerPageRequiredFlag = true;
1625            if(next_fs.find('.information_form').length === 0){
1626                if(isRequiredQuestion === true && !$(this).hasClass('ays-quiz-after-timer-end')){
1627                    if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
1628                        var customPerPageRequiredFlag = false;
1629                    }
1630                }
1631                if( isQuestionPerPageCustom && customPerPageValue != "" && customPerPageRequiredFlag ){
1632                    var custom_next_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_next').val();
1633                    var custom_prev_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_prev').val();
1634                    var questions_count_new = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').length;
1635                    if( typeof custom_next_sibilings_count != "undefined" && custom_next_sibilings_count != "" ){
1636                        var custom_next_sibilings_count_arr = custom_next_sibilings_count.split(',');
1637                        if (custom_next_sibilings_count_arr !== undefined && custom_next_sibilings_count_arr.length > 0) {
1638                            next_sibilings_count = parseInt( custom_next_sibilings_count_arr[0] );
1639                            $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page').val(next_sibilings_count);
1640
1641                            var shift_number = custom_next_sibilings_count_arr.shift();
1642                            var custom_prev_sibilings_count_arr = new Array();
1643                            if( typeof custom_prev_sibilings_count == 'undefined' || custom_prev_sibilings_count == "" ){
1644                                $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_prev').val(next_sibilings_count);
1645                            } else {
1646                                var custom_prev_sibilings_count_arr = custom_prev_sibilings_count.split(",");
1647                                custom_prev_sibilings_count_arr.push(shift_number);
1648
1649                                var custom_prev_sibilings_count_arr_new = custom_prev_sibilings_count_arr.join(",");
1650                                $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_prev').val(custom_prev_sibilings_count_arr_new);
1651                            }
1652
1653                            if( custom_next_sibilings_count_arr.length > 0 ){
1654                                var custom_next_sibilings_count_new_val = custom_next_sibilings_count_arr.join(',');
1655                                $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_next').val(custom_next_sibilings_count_new_val);
1656                            } else {
1657
1658                                var sum_prev_quesiton = 0;
1659                                for (var ii = 0; ii < custom_prev_sibilings_count_arr.length; ii++ ) {
1660                                    sum_prev_quesiton += parseInt( custom_prev_sibilings_count_arr[ii] );
1661                                }
1662                                var last_page_questions_count = parseInt(questions_count_new) - parseInt(sum_prev_quesiton);
1663                                if( last_page_questions_count != 0 ) {
1664                                    $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_next').val(last_page_questions_count);
1665                                } else {
1666                                    $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_next').val("");
1667                                }
1668                            }
1669                            var next_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page').val();
1670                        }
1671                    }
1672                }
1673
1674            }
1675
1676            // Display all questions on one page
1677            myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
1678            var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
1679
1680            // Enable finish button
1681            myOptions.enable_early_finish = ( myOptions.enable_early_finish ) ? myOptions.enable_early_finish : 'off';
1682            var enable_early_finish = (myOptions.enable_early_finish && myOptions.enable_early_finish == "on") ? true : false;
1683
1684            var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'on') ? true : false;
1685
1686            if ( quiz_display_all_questions ) {
1687                next_sibilings_count = questions_count;
1688            }
1689
1690            if(parseInt(next_sibilings_count)>0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))){
1691                if(parseInt(next_sibilings_count) >= questions_count){
1692                    next_sibilings_count = questions_count;
1693                }
1694
1695                var current_fs_index = $(this).parents('form.ays-quiz-form').find('.step').index($(this).parents('.step'));
1696                var new_current_fs_index = $(this).parents('form.ays-quiz-form').find('.step').index($(this).parents('form.ays-quiz-form').find('.step.active-step'));
1697                var next_fs_index = $(this).parents('form.ays-quiz-form').find('.step').index(next_fs);
1698
1699                if($(this).parents('.step').attr('data-question-id')){
1700                    if( isQuestionPerPageCustom && customPerPageValue != ""){
1701                        current_fs = $(this).parents('form.ays-quiz-form').find('.step').slice(parseInt(new_current_fs_index) - 1,next_fs_index);
1702                    } else {
1703                        current_fs = $(this).parents('form.ays-quiz-form').find('.step').slice(current_fs_index-parseInt(next_sibilings_count),current_fs_index+1);
1704                    }
1705                }else{
1706                    current_fs = $(this).parents('.step');
1707                }
1708                if(questions_count === curent_number){
1709                    if(current_fs.hasClass('.information_form').length !== 0){
1710                        current_fs.find('.ays_next').eq(current_fs.find('.ays_next').length-1).addClass('ays_timer_end');
1711                        current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(500);
1712                        $(this).parents('.ays-quiz-container').find('input.ays-quiz-end-date').val(GetFullDateTime());
1713                    }
1714
1715                    var timer2 = parseInt(ays_quiz_container.find('div.ays-quiz-timer').attr('data-timer'));
1716                    if (!isNaN(timer2) && myOptions.timer !== undefined) {
1717                        if (myOptions.timer === timer2 && timer2 !== 0) {
1718                            var myStartDate = new Date(Date.now() - aysDurationInSeconds * AYS_MS_PER_SECONDS);
1719                            var countdownEndTime = myStartDate.aysCustomFormat( "#YYYY#-#MM#-#DD# #hhhh#:#mm#:#ss#" );
1720                            $(this).parents('.ays-quiz-container').find('input.ays-quiz-end-date').val(countdownEndTime);
1721                        } else {
1722                            $(this).parents('.ays-quiz-container').find('input.ays-quiz-end-date').val(GetFullDateTime());
1723                        }
1724                    } else {
1725                        $(this).parents('.ays-quiz-container').find('input.ays-quiz-end-date').val(GetFullDateTime());
1726                    }
1727                }
1728                
1729
1730                if(curent_number != questions_count){
1731                    if(($(this).hasClass('ays_finish')) == false){
1732                        if (!($(this).hasClass('start_button'))) {
1733                            var count_per_page = Math.floor(questions_count/parseInt(next_sibilings_count));
1734                            var nextCountQuestionsPerPage = questions_count-curent_number;
1735                            var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
1736                            var final_width = ((curent_number+parseInt(next_sibilings_count)) / questions_count * 100) + "%";
1737                            if(nextCountQuestionsPerPage < parseInt(next_sibilings_count)){
1738                                final_width = ((curent_number+nextCountQuestionsPerPage) / questions_count * 100) + "%";
1739                            }
1740                            if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
1741                                if(nextCountQuestionsPerPage < parseInt(next_sibilings_count)){
1742                                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+parseInt(nextCountQuestionsPerPage)));
1743                                }else{
1744                                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+parseInt(next_sibilings_count)));
1745                                }
1746                            }else{
1747                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
1748                            }
1749                            $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
1750                        }
1751                    }
1752                }else{
1753                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
1754                    setTimeout(function () {
1755                        $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none');
1756                    },300)
1757                }
1758                var next_siblings = $(this).parents('.step').nextAll('.step').slice(0,parseInt(next_sibilings_count));
1759
1760                if($(this).parents('form.ays-quiz-form').find('div[data-question-id]').index($(this).parents('.step'))+1 !== $(this).parents('form').find('div[data-question-id]').length) {
1761                    for (var z = 0; z < next_siblings.length; z++) {
1762                        if (next_siblings.eq(z).attr('data-question-id') === undefined) {
1763                            next_siblings.splice(z);
1764                        }
1765                    }
1766                }else{
1767                    if(next_siblings.length !== 1) {
1768                        next_siblings.splice(next_siblings.length - 1);
1769                    }
1770                }
1771
1772                if ($(this).parents('form.ays-quiz-form').hasClass('enable_correction')) {
1773                    next_siblings.find('input[name^="ays_questions"]').each(function(){
1774                        if ($(this).parents('.ays-quiz-answers').find('.correct').length === 0 &&
1775                            $(this).parents('.ays-quiz-answers').find('.wrong').length === 0 &&
1776                            $(this).parents('.ays-quiz-answers').find('.ays-answered-text-input').length === 0) {
1777                            $(this).attr('disabled', false);
1778                        }
1779                    });
1780                }
1781
1782                for(var i=0 ;i<next_siblings.length-1;i++){
1783                    var nextQuestionType = next_siblings.eq(i).find('input[name^="ays_questions"]').attr('type');
1784                    var buttonsDiv = next_siblings.eq(i).find('.ays_buttons_div');
1785                    next_siblings.eq(i).find('.ays_previous').remove();
1786                    if(i === next_siblings.length-1 && next_siblings.eq(i).find('textarea[name^="ays_questions"]').attr('type')==='text'){
1787                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1788                        continue;
1789                    }
1790                    if(i === next_siblings.length-1 && nextQuestionType === 'checkbox'){
1791                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1792                        continue;
1793                    }
1794                    if(i === next_siblings.length-1 && nextQuestionType === 'number'){
1795                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1796                        continue;
1797                    }
1798                    if(i === next_siblings.length-1 && nextQuestionType === 'text'){
1799                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1800                        continue;
1801                    }
1802                    if(i === next_siblings.length-1 && nextQuestionType === 'date'){
1803                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1804                        continue;
1805                    }
1806                    next_siblings.eq(i).find('.ays_next').remove();
1807                    next_siblings.eq(i).find('.ays_early_finish').remove();
1808                }
1809
1810                // for(var i=0 ;i<next_siblings.length;i++){
1811                    // if ( i !== 0 ) {
1812                        // next_siblings.eq(i).find('.ays-export-quiz-button-container').remove();
1813                //     }
1814                // }
1815
1816                if ( quiz_display_all_questions ) {
1817                    next_siblings.find('.ays_previous').remove();
1818                }
1819
1820                if(current_fs.hasClass('ays-abs-fs')){
1821                    current_fs = $(this).parents('.step');
1822                    next_fs = $(this).parents('.step').next();
1823                    current_fs.removeClass('active-step');
1824                    var counterClass = "";
1825                    switch(ays_quiz_container.data('questEffect')){
1826                        case "shake":
1827                            counterClass = ays_quiz_container.data('questEffect');
1828                        break;
1829                        case "fade":
1830                            counterClass = "fadeIn";
1831                        break;
1832                        case "none":
1833                            counterClass = "";
1834                        break;
1835                        default:
1836                            counterClass = ays_quiz_container.data('questEffect');
1837                        break;
1838                    }
1839                    next_fs.find('.ays-question-counter').addClass(counterClass);
1840                }
1841
1842                var nextQuestionType = next_siblings.eq(next_siblings.length-1).find('input[name^="ays_questions"]').attr('type');
1843                var buttonsDiv = next_siblings.eq(next_siblings.length-1).find('.ays_buttons_div');
1844                var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val();
1845                if(myOptions.enable_arrows){
1846                    enableArrows = myOptions.enable_arrows == 'on' ? true : false;
1847                }else{
1848                    enableArrows = parseInt(enableArrows) == 1 ? true : false;
1849                }
1850
1851                if ( ! enable_early_finish ) {
1852                    buttonsDiv.find('i.ays_early_finish').addClass('ays_display_none');
1853                    buttonsDiv.find('input.ays_early_finish').addClass('ays_display_none');
1854                }
1855                
1856                var nextArrowIsDisabled = buttonsDiv.find('.ays_next_arrow').hasClass('ays_display_none');
1857                var nextButtonIsDisabled = buttonsDiv.find('.ays_next').hasClass('ays_display_none');
1858
1859                if(next_siblings.eq(next_siblings.length-1).find('textarea[name^="ays_questions"]').attr('type')==='text' && nextArrowIsDisabled && nextButtonIsDisabled){
1860                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1861                }
1862                if(next_siblings.eq(next_siblings.length-1).find('textarea[name^="ays_questions"]').attr('type') === 'text' && enableArrows){
1863                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1864                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1865                }
1866
1867
1868                if(nextQuestionType === 'checkbox' && nextArrowIsDisabled && nextButtonIsDisabled){
1869                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1870                }
1871                if(nextQuestionType === 'checkbox' && enableArrows){
1872                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1873                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1874                }
1875                if(nextQuestionType === 'number' && nextArrowIsDisabled && nextButtonIsDisabled){
1876                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1877                }
1878                if(nextQuestionType === 'number' && enableArrows){
1879                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1880                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1881                }
1882                if(nextQuestionType === 'text' && nextArrowIsDisabled && nextButtonIsDisabled){
1883                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1884                }
1885                if(nextQuestionType === 'text' && enableArrows){
1886                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1887                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1888                }
1889                if(nextQuestionType === 'date' && nextArrowIsDisabled && nextButtonIsDisabled){
1890                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1891                }
1892                if(nextQuestionType === 'date' && enableArrows){
1893                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1894                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1895                }
1896                if(nextQuestionType === 'matching' && nextArrowIsDisabled && nextButtonIsDisabled){
1897                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1898                }
1899                if(nextQuestionType === 'matching' && enableArrows){
1900                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
1901                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1902                }
1903                
1904                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
1905
1906                if(isRequiredQuestion === true && !$(this).hasClass('ays-quiz-after-timer-end')){
1907                    if(next_siblings.find('.information_form').length === 0){
1908                        var existsEmtpyQuestions = ays_quiz_is_question_required( current_fs );
1909
1910                        if( ! next_siblings.hasClass('ays-filled-required-qestions') ){
1911                            if(enableArrows){
1912                                buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
1913                            }else{
1914                                buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
1915                            }
1916                        }
1917
1918                        if ( next_siblings.eq( next_siblings.length - 1 ).hasClass('ays-custom-step') ) {
1919                            var customQuestionStep = next_siblings.eq( next_siblings.length - 1 );
1920                            if(enableArrows){
1921                                customQuestionStep.find('i.ays_next_arrow').removeAttr('disabled');
1922                                buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
1923                            }else{
1924                                customQuestionStep.find('input.ays_next').removeAttr('disabled');
1925                                buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1926                            }
1927                        }
1928
1929                        if( existsEmtpyQuestions === false ){
1930                            return false;
1931                        }else{
1932                            current_fs.addClass('ays-filled-required-qestions');
1933                        }
1934                    } else if ( next_siblings.find('.information_form').length > 0 ) {
1935                        if ( !($(this).hasClass('start_button')) && quiz_display_all_questions && !enableNextButton ) {
1936                            var quizContainer = $(e.target).parents('.ays-quiz-container');
1937                            var existsEmtpyQuestions = ays_quiz_is_question_required( quizContainer.find('div[data-question-id]') );
1938                            
1939                            if( ! next_siblings.hasClass('ays-filled-required-qestions') ){
1940                                if(enableArrows){
1941                                    buttonsDiv.find('i.ays_next_arrow.ays_finish').prop('disabled', false);
1942                                }else{
1943                                    buttonsDiv.find('input.ays_next.ays_finish').prop('disabled', false);
1944                                }
1945                            }
1946
1947                            if( existsEmtpyQuestions === false ){
1948                                return false;
1949                            }else{
1950                                current_fs.addClass('ays-filled-required-qestions');
1951                            }
1952                        }
1953                    }
1954                }
1955
1956                if (!($(this).hasClass('start_button'))) {
1957                    var minSelHasError = 0;
1958                    var minSelQuestions = next_siblings;
1959                   // if(($(this).hasClass('ays_finish')) == false){
1960                   //     minSelQuestions = next_siblings;
1961                   // }else{
1962                        minSelQuestions = current_fs;
1963                   // }
1964
1965                    for( var k = 0; k < minSelQuestions.length; k++ ){
1966                        if( $( minSelQuestions[k] ).find('.enable_min_selection_number').length > 0 ){
1967                            var checkedMinSelCount = aysCheckMinimumCountCheckbox( $( minSelQuestions[k] ), myQuizOptions );
1968                            if( ays_quiz_is_question_min_count( $( minSelQuestions[k] ), !checkedMinSelCount ) === true ){
1969                                if( checkedMinSelCount == true ){
1970                                    if(enableArrows){
1971                                        buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled');
1972                                        buttonsDiv.find('i.ays_next_arrow').prop('disabled', false);
1973                                    }else{
1974                                        buttonsDiv.find('input.ays_next').removeAttr('disabled');
1975                                        buttonsDiv.find('input.ays_next').prop('disabled', false);
1976                                    }
1977                                }else{
1978                                    if(enableArrows){
1979                                        buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
1980                                        buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
1981                                        buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
1982                                    }else{
1983                                        buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
1984                                        buttonsDiv.find('input.ays_next').prop('disabled', true);
1985                                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1986                                    }
1987                                    minSelHasError++;
1988                                }
1989                            }else{
1990                                if(enableArrows){
1991                                    buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
1992                                    buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
1993                                    buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
1994                                }else{
1995                                    buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
1996                                    buttonsDiv.find('input.ays_next').prop('disabled', true);
1997                                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
1998                                }
1999                                minSelHasError++;
2000                            }
2001                        }
2002                    }
2003
2004                    if( minSelHasError > 0 ){
2005                        return false;
2006                    }
2007                }
2008
2009                ays_quiz_container.find('.active-step').removeClass('active-step');
2010                next_siblings.eq(0).addClass('active-step');
2011                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_siblings);
2012
2013                if( !quizDisableInputFocusing ){
2014                    next_siblings.eq(0).find('.ays-text-input:first-child').trigger( "focus" );
2015
2016                    next_siblings.eq(0).find('.ays-text-input:first-child').trigger( "focus" );
2017                    if ( ! next_siblings.eq(0).find('.ays-text-input:first-child').is(":focus") ) {
2018                        setTimeout(function(e){
2019                            next_siblings.eq(0).find('.ays-text-input:first-child').trigger( "focus" );
2020                        },1001);
2021                    }
2022                }
2023
2024                setTimeout(function(){
2025                    if(next_siblings.find('.ays-text-field').length > 0){
2026                        if(next_siblings.find('.ays-text-field').width() < 250){
2027                            next_siblings.find('.ays-text-field').css({
2028                                'flex-wrap': 'wrap',
2029                                'justify-content': 'center',
2030                                'padding': '5px'
2031                            });
2032                            next_siblings.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px');
2033                        }
2034                    }
2035                },2000);
2036            }else{
2037                current_fs = $(this).parents('.step');
2038                next_fs = $(this).parents('.step').next();
2039
2040                if( aysThisQuizBullets !== null ){
2041                    var thisQuestionID = next_fs.data('questionId');
2042                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]').parents('.ays-quiz-questions-nav-item');
2043                    aysThisQuizBullets._navPage(thisBullet.index());
2044                }
2045
2046                var questions_count = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').length;
2047                var curent_number = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))+1;
2048                if(questions_count === curent_number){
2049                    if(current_fs.hasClass('.information_form').length !== 0){
2050                        current_fs.find('.ays_next').addClass('ays_timer_end');
2051                        current_fs.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp(500);
2052                        $(this).parents('.ays-quiz-container').find('input.ays-quiz-end-date').val(GetFullDateTime());
2053                    }
2054
2055                    var timer2 = parseInt(ays_quiz_container.find('div.ays-quiz-timer').attr('data-timer'));
2056                    if (!isNaN(timer2) && myOptions.timer !== undefined) {
2057                        if (myOptions.timer === timer2 && timer2 !== 0) {
2058                            var myStartDate = new Date(Date.now() - aysDurationInSeconds * AYS_MS_PER_SECONDS);
2059                            var countdownEndTime = myStartDate.aysCustomFormat( "#YYYY#-#MM#-#DD# #hhhh#:#mm#:#ss#" );
2060                            $(this).parents('.ays-quiz-container').find('input.ays-quiz-end-date').val(countdownEndTime);
2061                        } else {
2062                            $(this).parents('.ays-quiz-container').find('input.ays-quiz-end-date').val(GetFullDateTime());
2063                        }
2064                    } else {
2065                        $(this).parents('.ays-quiz-container').find('input.ays-quiz-end-date').val(GetFullDateTime());
2066                    }
2067                }
2068                if(curent_number != questions_count){
2069                    if(($(this).hasClass('ays_finish')) == false){
2070                        if (!($(this).hasClass('start_button'))) {
2071                            var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
2072                            var final_width = ((curent_number+1) / questions_count * 100) + "%";
2073                            if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
2074                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1));
2075                            }else{
2076                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
2077                            }
2078                            $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
2079                        }
2080                    }
2081                }else{
2082                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
2083                    setTimeout(function () {
2084                        $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none');
2085                    },300)
2086                }
2087                if (current_fs.hasClass('ays-abs-fs')) {
2088                    current_fs = $(this).parents('.step');
2089                    next_fs = $(this).parents('.step').next();
2090                    var counterClass = "";
2091                    switch(ays_quiz_container.data('questEffect')){
2092                        case "shake":
2093                            counterClass = ays_quiz_container.data('questEffect');
2094                        break;
2095                        case "fade":
2096                            counterClass = "fadeIn";
2097                        break;
2098                        case "none":
2099                            counterClass = "";
2100                        break;
2101                        default:
2102                            counterClass = ays_quiz_container.data('questEffect');
2103                        break;
2104                    }
2105                    next_fs.find('.ays-question-counter').addClass(counterClass);
2106                }
2107                current_fs.removeClass('active-step');
2108                next_fs.addClass('active-step');
2109                var nextQuestionType = next_fs.find('input[name^="ays_questions"]').attr('type');
2110                var buttonsDiv = next_fs.find('.ays_buttons_div');
2111                var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val();
2112
2113                if(myOptions.enable_arrows){
2114                    enableArrows = myOptions.enable_arrows == 'on' ? true : false;
2115                }else{
2116                    enableArrows = parseInt(enableArrows) == 1 ? true : false;
2117                }
2118                var nextArrowIsDisabled = buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none');
2119                var nextButtonIsDisabled = buttonsDiv.find('input.ays_next').hasClass('ays_display_none');
2120
2121                if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && nextArrowIsDisabled && nextButtonIsDisabled){
2122                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2123                }
2124                if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && enableArrows){
2125                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2126                   buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2127                }
2128
2129
2130                if(nextQuestionType === 'checkbox' && nextArrowIsDisabled && nextButtonIsDisabled){
2131                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2132                }
2133                if(nextQuestionType === 'checkbox' && enableArrows){
2134                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2135                   buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2136                }
2137
2138                if(nextQuestionType === 'number' && nextArrowIsDisabled && nextButtonIsDisabled){
2139                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2140                }
2141                if(nextQuestionType === 'number' && enableArrows){
2142                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2143                   buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2144                }
2145
2146                if(nextQuestionType === 'text' && nextArrowIsDisabled && nextButtonIsDisabled){
2147                   next_fs.find('.ays_buttons_div').find('input.ays_next').removeClass('ays_display_none');
2148                }
2149                if(nextQuestionType === 'text' && enableArrows){
2150                   next_fs.find('.ays_buttons_div').find('input.ays_next').addClass('ays_display_none');
2151                   next_fs.find('.ays_buttons_div').find('i.ays_next_arrow').removeClass('ays_display_none');
2152                }
2153
2154                if(nextQuestionType === 'date' && nextArrowIsDisabled && nextButtonIsDisabled){
2155                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2156                }
2157                if(nextQuestionType === 'date' && enableArrows){
2158                    buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2159                    buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2160                }
2161                if(next_fs.data('type') === 'matching' && nextArrowIsDisabled && nextButtonIsDisabled){
2162                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2163                }
2164                if(next_fs.data('type') === 'matching' && enableArrows){
2165                    buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2166                    buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2167                }
2168
2169                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
2170                var checkUserAnswered = false;
2171                if (next_fs.find('.ays-quiz-answers .ays-field textarea').length) {
2172                    nextQuestionType = 'text';
2173                }
2174
2175                if (next_fs.data('type') === 'matching') {
2176                    nextQuestionType = 'matching';
2177                } else if (next_fs.find('.ays-quiz-answers .ays-field select.ays-select').length) {
2178                    nextQuestionType = 'select';
2179                }
2180                
2181                if ( next_fs.hasClass('ays-custom-step') ) {
2182                    nextQuestionType = 'custom';
2183                }
2184
2185                switch (nextQuestionType){
2186                    case "radio":
2187                        checkUserAnswered = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').is(':checked');
2188                    break;
2189                    case "checkbox":
2190                        checkUserAnswered = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').is(':checked');
2191                    break;
2192                    case "number":
2193                        var questionTypeVal = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').val().length;
2194                        if (questionTypeVal !== 0) {
2195                            checkUserAnswered = true;
2196                        }
2197                    break;
2198                    case "text":
2199                        var questionTypeVal = next_fs.find('.ays-quiz-answers .ays-field textarea, .ays-quiz-answers .ays-field input[type="text"]').val();
2200                        if (questionTypeVal !== '') {
2201                            checkUserAnswered = true;
2202                        }
2203                    break;
2204                    case "date":
2205                        var questionTypeVal = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').val().length;
2206                        if (questionTypeVal !== 0) {
2207                            checkUserAnswered = true;
2208                        }
2209                    break;
2210                    case "select":
2211                        var questionTypeEl = next_fs.find('.ays-quiz-answers .ays-field select.ays-select option[data-chisht]');
2212                        questionTypeEl.each(function(){
2213                            var questionTypeVal = $(this).attr('selected');
2214                            if (questionTypeVal) {
2215                                checkUserAnswered = true;
2216                            }
2217                        });
2218                    break;
2219                    case "matching":
2220                        var questionTypeEl = next_fs.find('.ays-quiz-answers .ays-field select.ays-select option');
2221                        var checkedCount = 0;
2222                        var choicesCount = next_fs.find('.ays-quiz-answers .ays-field.ays-matching-field-option').length;
2223                        questionTypeEl.each(function(){
2224                            var questionTypeVal = $(this).attr('selected');
2225                            if (questionTypeVal) {
2226                                checkedCount++;
2227                            }
2228                        });
2229                        if( checkedCount === choicesCount ) {
2230                            checkUserAnswered = true;
2231                        }
2232                    break;
2233                    case "custom":
2234                        checkUserAnswered = true;
2235                    break;
2236                    default:
2237                        checkUserAnswered = next_fs.find('.ays-quiz-answers .ays-field input[type="'+ nextQuestionType +'"]').prop('ckecked');
2238                    break;
2239                }
2240                if(isRequiredQuestion === true){
2241                    if(next_fs.find('.information_form').length === 0){
2242                        var newNextQuestionType = next_fs.attr('data-type');
2243
2244                        if(enableArrows){
2245                            if (! checkUserAnswered) {
2246                                buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
2247                            }else{
2248                                if( nextQuestionType == 'custom' ){
2249                                    buttonsDiv.find('i.ays_next').removeAttr('disabled');
2250                                    buttonsDiv.find('i.ays_finish').removeAttr('disabled');
2251                                }
2252                                if( newNextQuestionType !== "fill_in_blank" ){
2253                                    buttonsDiv.find('i.ays_early_finish').removeAttr('disabled');
2254                                }
2255                            }
2256                        }else{
2257                            if (! checkUserAnswered) {
2258                                buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
2259                            }else{
2260                                if( nextQuestionType == 'custom' ){
2261                                    buttonsDiv.find('input.ays_next').removeAttr('disabled');
2262                                    buttonsDiv.find('input.ays_finish').removeAttr('disabled');
2263                                }
2264                                if( newNextQuestionType !== "fill_in_blank" ){
2265                                    buttonsDiv.find('input.ays_early_finish').removeAttr('disabled');
2266                                }
2267                            }
2268                        }
2269                    }
2270                }
2271
2272                var isAnimate = true;
2273                var timerType = myOptions.quiz_timer_type ? myOptions.quiz_timer_type : 'quiz_timer';
2274                if( isRequiredQuestion && myOptions.enable_timer && myOptions.enable_timer === 'on' && timerType === 'question_timer' ) {
2275                    var qid = checkQuestionTimer(ays_quiz_container, quizId);
2276                    if ($(this).hasClass('ays_finish') && qid !== false) {
2277                        isAnimate = false;
2278                    }
2279                }
2280
2281                if ( isAnimate ) {
2282                    aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
2283                }
2284
2285                if( !quizDisableInputFocusing  ){
2286                    next_fs.find('.ays-text-input:first-child').trigger( "focus" );
2287                    if ( ! next_fs.find('.ays-text-input:first-child').is(":focus") ) {
2288                        setTimeout(function(e){
2289                            next_fs.find('.ays-text-input:first-child').trigger( "focus" );
2290                        },1001);
2291                    }
2292                }
2293
2294                setTimeout(function(){
2295                    if(next_fs.find('.ays-text-field').length > 0){
2296                        if(next_fs.find('.ays-text-field').width() < 250){
2297                            next_fs.find('.ays-text-field').css({
2298                                'flex-wrap': 'wrap',
2299                                'justify-content': 'center',
2300                                'padding': '5px'
2301                            });
2302                            next_fs.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px');
2303                        }
2304                    }
2305                },2000);
2306            }
2307            if( $(this).parents('.ays-questions-container').length > 0 ){
2308                if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top || $(this).parents('.ays-questions-container').offset().top > 500){
2309                    ays_quiz_container.goTo( myOptions );
2310                }
2311            }
2312            if(current_fs.find('audio').length > 0){
2313                current_fs.find('audio').each(function(e, el){
2314                    el.pause();
2315                });
2316            }
2317            if(current_fs.find('video').length > 0){
2318                current_fs.find('video').each(function(e, el){
2319                    el.pause();
2320                });
2321            }
2322
2323            //Current
2324            if(current_fs.find('audio').length > 0){
2325                var sound_src = next_fs.find('audio').attr('src');
2326                if (typeof sound_src !== 'undefined'){
2327                    var audio = next_fs.find('audio').get(0);
2328                    audio.pause();
2329                    audio.currentTime = 0;
2330                }
2331            }
2332
2333            //Next
2334            var enableAudioAutoplay = (myOptions.enable_audio_autoplay && myOptions.enable_audio_autoplay == 'on') ? true : false;
2335            if(next_fs.find('audio').length > 0){
2336                if(enableAudioAutoplay){
2337                    var sound_src = next_fs.find('audio').attr('src');
2338                    if (typeof sound_src !== 'undefined'){
2339                        var audio = next_fs.find('audio').get(0);
2340                        audio.currentTime = 0;
2341                        audio.play();
2342                    }
2343                }
2344            }
2345
2346            if ('speechSynthesis' in window) {
2347                speechSynthesis.cancel();
2348            }
2349
2350            //Custom type
2351            //Checking Next button and Arrows filelds
2352            var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'off') ? true : false;
2353            var enableArrows = (myOptions.enable_arrows && myOptions.enable_arrows == 'on') ? true : false;
2354            if(enableNextButton){
2355                if(next_fs.hasClass('ays-custom-step')){
2356                    if (enableArrows) {
2357                        next_fs.find('.ays_buttons_div i.ays_next.action-button.ays_arrow').removeClass('ays_display_none');
2358                    }else{
2359                        next_fs.find('.ays_buttons_div input.ays_next.action-button').removeClass('ays_display_none');
2360                    }
2361                }
2362            }
2363
2364            setTimeout(function (){
2365                questionTimer( next_fs, next_fs.data('questionId') );
2366            }, 1);
2367            aysResizeiFrame();
2368        });
2369
2370
2371        $(document).find('.ays_questions_nav_question').on('click', function(e){
2372            e.preventDefault();
2373            var questionId = $(this).data('id');
2374            ays_quiz_container = $(this).parents(".ays-quiz-wrap").find(".ays-quiz-container");
2375
2376            if (animating) return false;
2377            animating = true;
2378            current_fs = ays_quiz_container.find('div.active-step[data-question-id]');
2379            next_fs = ays_quiz_container.find('div[data-question-id="'+questionId+'"]');
2380
2381            var quizDisableInputFocusing = (myOptions.quiz_disable_input_focusing && myOptions.quiz_disable_input_focusing == "on") ? true : false;
2382
2383                current_fs.removeClass('active-step');
2384                next_fs.addClass('active-step');
2385                var nextQuestionType = next_fs.find('input[name^="ays_questions"]').attr('type');
2386                var buttonsDiv = next_fs.find('.ays_buttons_div');
2387                var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val();
2388
2389                var questions_count = $(this).parents('.ays-quiz-wrap').find('div[data-question-id]').length;
2390                var curent_number = $(this).parents('.ays-quiz-wrap').find('div[data-question-id]').index( ays_quiz_container.find('div[data-question-id="'+questionId+'"]') );
2391
2392                var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
2393                var final_width = ((curent_number+1) / questions_count * 100) + "%";
2394
2395                if( ays_quiz_container.find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
2396                    ays_quiz_container.find('.ays-live-bar-percent').text(parseInt(curent_number+1));
2397                }else{
2398                    ays_quiz_container.find('.ays-live-bar-percent').text(parseInt(final_width));
2399                }
2400                ays_quiz_container.find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
2401
2402                if ( next_fs.hasClass('ays-custom-step') ) {
2403                    nextQuestionType = 'custom';
2404                }
2405
2406                if(myOptions.enable_arrows){
2407                    enableArrows = myOptions.enable_arrows == 'on' ? true : false;
2408                }else{
2409                    enableArrows = parseInt(enableArrows) == 1 ? true : false;
2410                }
2411                var nextArrowIsDisabled = buttonsDiv.find('.ays_next_arrow').hasClass('ays_display_none');
2412                var nextButtonIsDisabled = buttonsDiv.find('.ays_next').hasClass('ays_display_none');
2413
2414                if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && nextArrowIsDisabled && nextButtonIsDisabled){
2415                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2416                }
2417                if(next_fs.find('textarea[name^="ays_questions"]').attr('type')==='text' && enableArrows){
2418                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2419                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2420                }
2421
2422
2423                if(nextQuestionType === 'checkbox' && nextArrowIsDisabled && nextButtonIsDisabled){
2424                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2425                }
2426                if(nextQuestionType === 'checkbox' && enableArrows){
2427                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2428                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2429                }
2430
2431                if(nextQuestionType === 'number' && nextArrowIsDisabled && nextButtonIsDisabled){
2432                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2433                }
2434                if(nextQuestionType === 'number' && enableArrows){
2435                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2436                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2437                }
2438
2439                if(nextQuestionType === 'text' && nextArrowIsDisabled && nextButtonIsDisabled){
2440                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2441                }
2442                if(nextQuestionType === 'text' && enableArrows){
2443                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2444                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2445                }
2446
2447                if(nextQuestionType === 'short_text' && nextArrowIsDisabled && nextButtonIsDisabled){
2448                   buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2449                }
2450                if(nextQuestionType === 'short_text' && enableArrows){
2451                   buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2452                   buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2453                }
2454
2455                if(nextQuestionType === 'date' && nextArrowIsDisabled && nextButtonIsDisabled){
2456                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2457                }
2458                if(nextQuestionType === 'date' && enableArrows){
2459                    buttonsDiv.find('input.ays_next').addClass('ays_display_none');
2460                    buttonsDiv.find('.ays_next_arrow').removeClass('ays_display_none');
2461                }
2462
2463                if(enableArrows){
2464                    if( nextQuestionType == 'custom' ){
2465                        buttonsDiv.find('i.ays_next').removeAttr('disabled');
2466                        buttonsDiv.find('i.ays_finish').removeAttr('disabled');
2467                        buttonsDiv.find('i.ays_early_finish').removeAttr('disabled');
2468                    }
2469                }else{
2470                    if( nextQuestionType == 'custom' ){
2471                        buttonsDiv.find('input.ays_next').removeAttr('disabled');
2472                        buttonsDiv.find('input.ays_finish').removeAttr('disabled');
2473                        buttonsDiv.find('input.ays_early_finish').removeAttr('disabled');
2474                    }
2475                }
2476
2477                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
2478
2479                if( !quizDisableInputFocusing ){
2480                    next_fs.find('.ays-text-input:first-child').trigger( "focus" );
2481                }
2482
2483                setTimeout(function(){
2484                    if(next_fs.find('.ays-text-field').length > 0){
2485                        if(next_fs.find('.ays-text-field').width() < 250){
2486                            next_fs.find('.ays-text-field').css({
2487                                'flex-wrap': 'wrap',
2488                                'justify-content': 'center',
2489                                'padding': '5px'
2490                            });
2491                            next_fs.find('.ays-text-field').find('input.ays-text-input').css('margin-bottom', '5px');
2492                        }
2493                    }
2494                },2000);
2495            // }
2496
2497            // if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top || $(this).parents('.ays-questions-container').offset().top > 500){
2498            //     ays_quiz_container.goTo();
2499            // }
2500            if(current_fs.find('audio').length > 0){
2501                current_fs.find('audio').each(function(e, el){
2502                    el.pause();
2503                });
2504            }
2505            if(current_fs.find('video').length > 0){
2506                current_fs.find('video').each(function(e, el){
2507                    el.pause();
2508                });
2509            }
2510
2511            questionTimer( next_fs, next_fs.data('questionId') );
2512        });
2513
2514        $(document).find('.ays_previous').on("click", function(e){
2515            ays_quiz_container = $(this).parents(".ays-quiz-container");
2516
2517            var enableArrows = ays_quiz_container.find(".ays-questions-container .ays_qm_enable_arrows").val();
2518            if(myOptions.enable_arrows){
2519                enableArrows = myOptions.enable_arrows == 'on' ? true : false;
2520            }else{
2521                enableArrows = parseInt(enableArrows) == 1 ? true : false;
2522            }
2523
2524            if(typeof explanationTimeout != 'undefined'){
2525                clearTimeout(explanationTimeout);
2526
2527                var thisButtonsDiv = $(this).parents(".ays_buttons_div");
2528                setTimeout(function(){
2529                    if (thisButtonsDiv.find('input.ays_next').hasClass('ays_display_none') &&
2530                        thisButtonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) {
2531                        if(enableArrows){
2532                            thisButtonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2533                        }else{
2534                            thisButtonsDiv.find('input.ays_next').removeClass('ays_display_none');
2535                        }
2536                    }
2537                }, 1000);
2538            }
2539
2540            if(animating) return false;
2541            animating = true;
2542
2543            var next_sibilings_count = ays_quiz_container.find('.ays_question_count_per_page').val();
2544
2545            var isQuestionPerPageCustom = (myOptions.question_count_per_page_type && myOptions.question_count_per_page_type == "custom") ? true : false;
2546            var customPerPageValue = (myOptions.question_count_per_page_custom_order && myOptions.question_count_per_page_custom_order != "") ? myOptions.question_count_per_page_custom_order : "";
2547            var quizDisableInputFocusing = (myOptions.quiz_disable_input_focusing && myOptions.quiz_disable_input_focusing == "on") ? true : false;
2548
2549            if( isQuestionPerPageCustom && customPerPageValue != ""){
2550                var custom_next_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_next').val();
2551                var custom_prev_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_prev').val();
2552                var questions_count_new = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').length;
2553                if( typeof custom_prev_sibilings_count != "undefined" && custom_prev_sibilings_count != "" ){
2554                    var custom_prev_sibilings_count_arr = custom_prev_sibilings_count.split(',');
2555                    var custom_next_sibilings_count_arr = custom_next_sibilings_count.split(',');
2556                    if (custom_prev_sibilings_count_arr !== undefined && custom_prev_sibilings_count_arr.length > 0) {
2557                        var pop_number = custom_prev_sibilings_count_arr.pop();
2558                        next_sibilings_count = parseInt( custom_prev_sibilings_count_arr[ custom_prev_sibilings_count_arr.length - 1 ] );
2559
2560                        $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page').val(next_sibilings_count)
2561
2562                        if( typeof custom_prev_sibilings_count == 'undefined' || custom_prev_sibilings_count == "" ){
2563                            $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_prev').val(next_sibilings_count);
2564                        } else {
2565                            var custom_prev_sibilings_count_arr = custom_prev_sibilings_count.split(",");
2566                            custom_prev_sibilings_count_arr.pop();
2567
2568                            var custom_prev_sibilings_count_arr_new = custom_prev_sibilings_count_arr.join(",");
2569                            $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_prev').val(custom_prev_sibilings_count_arr_new);
2570                        }
2571
2572                        custom_next_sibilings_count_arr = custom_next_sibilings_count_arr.filter(word => word != "");
2573
2574                        if( custom_next_sibilings_count_arr.length > 0 ){
2575                            custom_next_sibilings_count_arr.unshift(pop_number);
2576                            var custom_next_sibilings_count_new_val = custom_next_sibilings_count_arr.join(',');
2577                            $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_next').val(custom_next_sibilings_count_new_val);
2578                        } else {
2579
2580                            var sum_prev_quesiton = 0;
2581                            for (var ii = 0; ii < custom_prev_sibilings_count_arr.length; ii++ ) {
2582                                sum_prev_quesiton += parseInt( custom_prev_sibilings_count_arr[ii] );
2583                            }
2584                            var last_page_questions_count = parseInt(questions_count_new) - parseInt(sum_prev_quesiton);
2585                            if( last_page_questions_count != 0 ) {
2586                                $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_next').val(last_page_questions_count);
2587                            } else {
2588                                $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page_custom_next').val("");
2589                            }
2590                        }
2591                    }
2592                }
2593            }
2594
2595            if(parseInt(next_sibilings_count)>0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))){
2596                var questions_count = ays_quiz_container.find('div[data-question-id]').length;
2597                var curent_number_of_this = ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) + 1;
2598                var curent_number = ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) - parseInt(next_sibilings_count) + 1;
2599                var count_per_page = questions_count%parseInt(next_sibilings_count);
2600                var nextCountQuestionsPerPage = questions_count-curent_number;
2601                if(count_per_page > 0 && curent_number_of_this == questions_count){
2602                    curent_number = ays_quiz_container.find('div[data-question-id]').index($(this).parents('div[data-question-id]')) - count_per_page + 1;
2603                }
2604
2605                var current_first_fs_index = ays_quiz_container.find('div[data-question-id]').index(ays_quiz_container.find('.active-step').eq(0));
2606                var next_fs = ays_quiz_container.find('div[data-question-id]').slice((current_first_fs_index - parseInt(next_sibilings_count)), current_first_fs_index);
2607
2608                var new_current_fs_index = $(this).parents('form.ays-quiz-form').find('.step').index($(this).parents('form.ays-quiz-form').find('.step.active-step'));
2609                var next_fs_index = $(this).parents('form.ays-quiz-form').find('.step').index(next_fs);
2610
2611                if (!($(this).hasClass('start_button'))) {
2612                    var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
2613                    var final_width = ((curent_number) / questions_count * 100) + "%";
2614                    if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
2615                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number));
2616                    }else{
2617                        $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
2618                    }
2619                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
2620                }
2621                var current_fs_index = ays_quiz_container.find('div[data-question-id]').index(ays_quiz_container.find('.active-step').eq(0));
2622
2623                if($(this).parents('.step').attr('data-question-id')){
2624                    if( isQuestionPerPageCustom && customPerPageValue != ""){
2625                        if( custom_next_sibilings_count_arr.length == 0 ){
2626                            current_fs = ays_quiz_container.find('div[data-question-id]').slice(current_fs_index,questions_count);
2627                        } else {
2628                            current_fs = ays_quiz_container.find('div[data-question-id]').slice(current_fs_index,current_fs_index+parseInt(pop_number)+1);
2629                        }
2630                    } else {
2631                        current_fs = ays_quiz_container.find('div[data-question-id]').slice(current_fs_index,current_fs_index+parseInt(next_sibilings_count));
2632                    }
2633
2634                    // current_fs = ays_quiz_container.find('div[data-question-id]').slice(current_fs_index,current_fs_index+parseInt(next_sibilings_count));
2635                }else{
2636                    current_fs = $(this).parents('.step');
2637                }
2638
2639                var buttonsDiv = next_fs.find('.ays_buttons_div');
2640                var enableArrows = $(document).find(".ays-questions-container .ays_qm_enable_arrows").val();
2641                if(myOptions.enable_arrows){
2642                    enableArrows = myOptions.enable_arrows == 'on' ? true : false;
2643                }else{
2644                    enableArrows = parseInt(enableArrows) == 1 ? true : false;
2645                }
2646
2647                if (buttonsDiv.find('input.ays_next').hasClass('ays_display_none') &&
2648                    buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) {
2649                    if(enableArrows){
2650                        buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2651                    }else{
2652                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2653                    }
2654                }
2655
2656                ays_quiz_container.find('div[data-question-id]').eq(current_fs_index).removeClass('active-step');
2657                next_fs.eq(0).addClass('active-step')
2658                if ($(this).parents('form.ays-quiz-form').hasClass('enable_correction')) {
2659                    if (next_fs.find('.correct').length !== 0 || $(this).parents('div[data-question-id]').prev().find('.wrong').length !== 0) {
2660                        next_fs.find('input[name^="ays_questions"]').on('click',function () {
2661                            var is_user_answer_correct = $(this).parent().find('.correct').length;
2662                            var is_user_answer_wrong = $(this).parent().find('.wrong').length;
2663                            if (is_user_answer_correct !== 0 || is_user_answer_wrong !== 0) {
2664                                return false;
2665                            }
2666                        });
2667                    }
2668                }
2669
2670                if ($(this).parents('form.ays-quiz-form').hasClass('enable_correction')) {
2671                    next_fs.find('input[name^="ays_questions"]').each(function(){
2672                        if ($(this).parents('.ays-quiz-answers').find('.correct').length === 0 &&
2673                            $(this).parents('.ays-quiz-answers').find('.wrong').length === 0 &&
2674                            $(this).parents('.ays-quiz-answers').find('.ays-answered-text-input').length === 0) {
2675                            $(this).attr('disabled', false);
2676                        }
2677                    });
2678                }
2679                
2680                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
2681                if( !quizDisableInputFocusing ){
2682                    next_fs.eq(0).find('.ays-text-input:first-child').trigger( "focus" );
2683                    
2684                    next_fs.eq(0).find('.ays-text-input:first-child').trigger( "focus" );
2685                    if ( ! next_fs.eq(0).find('.ays-text-input:first-child').is(":focus") ) {
2686                        setTimeout(function(e){
2687                            next_fs.eq(0).find('.ays-text-input:first-child').trigger( "focus" );
2688                        },1001);
2689                    }
2690                }
2691            }else{
2692                if ($(this).parents('div[data-question-id]').prev().find('.correct').length === 0 &&
2693                    $(this).parents('div[data-question-id]').prev().find('.wrong').length === 0 &&
2694                    $(this).parents('div[data-question-id]').prev().find('.ays-answered-text-input').length === 0) {
2695                    $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', false);
2696                }else{
2697                    $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', true);
2698                    if( $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('type') == 'checkbox' ){
2699                        $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"]').attr('disabled', false);
2700                        $(this).parents('div[data-question-id]').prev().find('input[name^="ays_questions"][type="radio"]').on('click',function () {
2701                            return false;
2702                        });
2703                    }
2704                }
2705
2706                current_fs = $(this).parents('.step');
2707                next_fs = $(this).parents('.step').prev();
2708
2709
2710                if( aysThisQuizBullets !== null ){
2711                    var thisQuestionID = next_fs.data('questionId');
2712                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]').parents('.ays-quiz-questions-nav-item');
2713                    aysThisQuizBullets._navPage(thisBullet.index());
2714                }
2715
2716                var buttonsDiv = next_fs.find('.ays_buttons_div');
2717
2718                if (buttonsDiv.find('input.ays_next').hasClass('ays_display_none') &&
2719                    buttonsDiv.find('i.ays_next_arrow').hasClass('ays_display_none')) {
2720                    if(enableArrows){
2721                        buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
2722                        buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled');
2723                        buttonsDiv.find('i.ays_early_finish').removeAttr('disabled');
2724                        buttonsDiv.find('i.ays_next_arrow').removeProp('disabled');
2725                        buttonsDiv.find('i.ays_early_finish').removeProp('disabled');
2726                    }else{
2727                        buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
2728                        buttonsDiv.find('input.ays_next').removeAttr('disabled');
2729                        buttonsDiv.find('input.ays_early_finish').removeAttr('disabled');
2730                        buttonsDiv.find('input.ays_next').removeProp('disabled');
2731                        buttonsDiv.find('input.ays_early_finish').removeProp('disabled');
2732                    }
2733                }
2734
2735                if (current_fs.hasClass('ays-abs-fs')) {
2736                    current_fs = $(this).parents('.step');
2737                    next_fs = $(this).parents('.step').prev();
2738                    var counterClass = "";
2739                    switch(ays_quiz_container.data('questEffect')){
2740                        case "shake":
2741                            counterClass = ays_quiz_container.data('questEffect');
2742                        break;
2743                        case "fade":
2744                            counterClass = "fadeIn";
2745                        break;
2746                        case "none":
2747                            counterClass = "";
2748                        break;
2749                        default:
2750                            counterClass = ays_quiz_container.data('questEffect');
2751                        break;
2752                    }
2753                    next_fs.find('.ays-question-counter').addClass(counterClass);
2754                }
2755                current_fs.removeClass('active-step');
2756                next_fs.addClass('active-step');
2757
2758                var questions_count = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').length;
2759                var curent_number = $(this).parents('form.ays-quiz-form').find('div[data-question-id]').index($(this).parents('div[data-question-id]'))-1;
2760                if(curent_number != questions_count){
2761                    if(($(this).hasClass('ays_finish')) == false){
2762                        if (!($(this).hasClass('start_button'))) {
2763                            var current_width = $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').width();
2764                            var final_width = ((curent_number+1) / questions_count * 100) + "%";
2765                            if($(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
2766                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(curent_number+1));
2767                            }else{
2768                                $(this).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(parseInt(final_width));
2769                            }
2770                            $(this).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({'width': final_width}, 1000);
2771                        }
2772                    }
2773                }else{
2774                    $(this).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
2775                    setTimeout(function () {
2776                        $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none');
2777                    },300)
2778                }
2779                aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
2780
2781                if( !quizDisableInputFocusing ){
2782                    next_fs.find('.ays-text-input:first-child').trigger( "focus" );
2783
2784                    next_fs.find('.ays-text-input:first-child').trigger( "focus" );
2785                    if ( ! next_fs.find('.ays-text-input:first-child').is(":focus") ) {
2786                        setTimeout(function(e){
2787                            next_fs.find('.ays-text-input:first-child').trigger( "focus" );
2788                        },1001);
2789                    }
2790                }
2791            }
2792            if( $(this).parents('.ays-questions-container').length > 0 ){
2793                if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top || $(this).parents('.ays-questions-container').offset().top > 500){
2794                    ays_quiz_container.goTo( myOptions );
2795                }
2796            }
2797            if(current_fs.find('audio').length > 0){
2798                current_fs.find('audio').each(function(e, el){
2799                    el.pause();
2800                });
2801            }
2802            if(current_fs.find('video').length > 0){
2803                current_fs.find('video').each(function(e, el){
2804                    el.pause();
2805                });
2806            }
2807
2808            //Current
2809            if(current_fs.find('audio').length > 0){
2810                var sound_src = next_fs.find('audio').attr('src');
2811                if (typeof sound_src !== 'undefined'){
2812                    var audio = next_fs.find('audio').get(0);
2813                    audio.pause();
2814                    audio.currentTime = 0;
2815                }
2816            }
2817
2818            //Previous
2819            var enableAudioAutoplay = (myOptions.enable_audio_autoplay && myOptions.enable_audio_autoplay == 'on') ? true : false;
2820            if(next_fs.find('audio').length > 0){
2821                if(enableAudioAutoplay){
2822                    var sound_src = next_fs.find('audio').attr('src');
2823                    if (typeof sound_src !== 'undefined'){
2824                        var audio = next_fs.find('audio').get(0);
2825                        audio.currentTime = 0;
2826                        audio.play();
2827                    }
2828                }
2829            }
2830
2831            if ('speechSynthesis' in window) {
2832                speechSynthesis.cancel();
2833            }
2834
2835            questionTimer( next_fs, next_fs.data('questionId') );
2836            aysResizeiFrame();
2837        });
2838
2839        // $(document).find('.ays-quiz-container input').on('focus',function () {
2840        //     $(window).on('keydown',function (event) {
2841        //         if(event.keyCode === 13){
2842        //             return false;
2843        //         }
2844        //     });
2845        // });
2846
2847        // $(document).find('.ays-quiz-container input').on('blur',function () {
2848        //     $(window).off('keydown');
2849        // });
2850        
2851        $(document).on('click', '.ays-quiz-container .ays_question_hint', function (e) {
2852            e.preventDefault();
2853            $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').toggleClass('z_index_0');
2854            $(e.target).parent().find('.ays_question_hint_text').toggleClass('show_hint');
2855            if($(e.target).parent().find('.ays_question_hint_text').hasClass('show_hint')){
2856                $(window).on('click', function(ev){
2857                    if( ! ( $(ev.target).hasClass('ays_question_hint_text') || $(ev.target).hasClass('ays_question_hint') ) ){
2858                        $(e.target).parent().find('.ays_question_hint_text').removeClass('show_hint');
2859                        $(e.target).parents('.ays-quiz-container').find('.ays_music_sound').removeClass('z_index_0');
2860                    }
2861                });
2862            }
2863        });
2864
2865        $(document).on('click', '.ays-quiz-container .ays-export-quiz-button-container .ays-export-quiz-button-more-icon-box', function (e) {
2866            e.preventDefault();
2867
2868            var _this = $(this);
2869            var parent = $(e.target).parents('.ays-export-quiz-button-container');
2870            parent.find('.ays-export-quiz-button-more-box').toggleClass('show-more-buttons');
2871        });
2872
2873        $(document).on('click' , function(e){
2874            if( !$(e.target).hasClass('ays-export-quiz-button-more-icon-box') && $(e.target).parents('.ays-export-quiz-button-container').length == 0 ){
2875                if($(e.target).closest('.ays-export-quiz-button-more-box').length != 0){
2876                } 
2877                else{
2878                    if( $(document).find(".ays-export-quiz-button-more-box").hasClass('show-more-buttons') ) {
2879                        $(document).find('.ays-export-quiz-button-more-box').removeClass('show-more-buttons');
2880                    }
2881                }
2882            }
2883        });
2884
2885        $(document).on('click', '.ays-field', function() {
2886            if ($(this).find(".select2").hasClass('select2-container--open')) {
2887                $(this).find('b[role="presentation"]').removeClass('ays_fa ays_fa_chevron_down');
2888                $(this).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_up');
2889            } else {
2890                $(this).find('b[role="presentation"]').removeClass('ays_fa ays_fa_chevron_up');
2891                $(this).find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down');
2892            }
2893        });
2894
2895        $(document).find('select.ays-select').on("select2:selecting", function(e){
2896            $(this).parents('.ays-quiz-container').find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down');
2897        });
2898        
2899        $(document).find('select.ays-select').on("select2:opening", function(e){
2900            var _this = $(this)
2901            setTimeout(function (){
2902                _this.parents('.ays-quiz-container').css('z-index', 1);
2903                _this.parents('.step').css('z-index', 1);
2904            }, 1);
2905        });
2906
2907        $(document).find('select.ays-select').on("select2:closing", function(e){
2908            $(this).parents('.ays-quiz-container').find('b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down');
2909            $(this).parents('.ays-quiz-container').css('z-index', 'initial');
2910            $(this).parents('.step').css('z-index', 'initial');
2911        });
2912        
2913        $(document).find('select.ays-select').on("select2:select", function(e){
2914            var quizContainer = $(e.target).parents('.ays-quiz-container');
2915            var quizId = $(this).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
2916
2917            var _this = $(this);
2918            var parentStep = _this.parents('.step');
2919            var quizForm = quizContainer.find('form.ays-quiz-form');
2920            var questionId = parentStep.data('questionId');
2921            var questionType = parentStep.data('type');
2922
2923            var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0);
2924            var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0);
2925            var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false;
2926            var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
2927            var explanationTime = myOptions.explanation_time && myOptions.explanation_time != "" ? parseInt(myOptions.explanation_time) : 4;
2928            var next_sibilings_count = quizContainer.find('.ays_question_count_per_page').val();
2929            var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'on') ? true : false;
2930            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
2931            var thankYouStep = quizContainer.find('div.step.ays_thank_you_fs');
2932            var infoFormLast = thankYouStep.prev().find('div.information_form');
2933
2934            // Strong calculation of answers score
2935            myOptions.checkbox_score_by = ( myOptions.checkbox_score_by ) ? myOptions.checkbox_score_by : 'off';
2936            var checkbox_score_by = (myOptions.checkbox_score_by && myOptions.checkbox_score_by == "on") ? true : false;
2937
2938            // Display all questions on one page
2939            myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
2940            var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
2941
2942            var disableQuestions = false;
2943            if( parseInt( next_sibilings_count ) > 0 || quiz_display_all_questions == true ){
2944                disableQuestions = true;
2945            }
2946
2947            myOptions.quiz_waiting_time = ( myOptions.quiz_waiting_time ) ? myOptions.quiz_waiting_time : "off";
2948            var quizWaitingTime = (myOptions.quiz_waiting_time && myOptions.quiz_waiting_time == "on") ? true : false;
2949
2950            myOptions.enable_next_button = ( myOptions.enable_next_button ) ? myOptions.enable_next_button : "off";
2951            var quizNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == "on") ? true : false;
2952
2953            if ( quizWaitingTime && !quizNextButton) {
2954                explanationTime += 2;
2955            }
2956            var data = e.params.data;
2957            var this_select_value = data.id;
2958            $(this).find("option").removeAttr("selected");
2959            $(this).find('option[value="'+this_select_value+'"]').attr("selected", true);
2960
2961            var quizWaitingCountDownDate = new Date().getTime() + (explanationTime * 1000);
2962            var thisAnswerOptions = myQuizOptions[questionId];
2963
2964            var selectOptions = _this.children("option[data-chisht]");
2965            for(var j = 0; j < selectOptions.length; j++){
2966                var currnetSelectOption = $(selectOptions[j]);
2967                var _answerId = currnetSelectOption.val();
2968
2969                if( typeof questionId != "undefined" && questionId !== null && quizForm.hasClass('enable_correction') ){
2970
2971                    var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer.length <= 0 ? new Array() : myQuizOptions[questionId].question_answer;
2972                    var ifCorrectAnswer = thisQuestionCorrectAnswer[_answerId] == '' ? '' : thisQuestionCorrectAnswer[_answerId];
2973
2974                    if( typeof ifCorrectAnswer != "undefined" ){
2975                        parentStep.find('.ays-field input[data-id="'+ _answerId +'"][name="ays_answer_
2975correct[]"]').val(ifCorrectAnswer);
2976                        currnetSelectOption.attr('data-chisht', ifCorrectAnswer);
2977                    }
2978                }
2979            }
2980
2981            if( questionType === 'matching' ){
2982                var choice = thisAnswerOptions.question_answer[ this_select_value ];
2983                var choicesCount = $(e.target).parents('div[data-question-id]').find('.ays-field.ays-matching-field-option').length;
2984                var answeredChoicesCount = 0; //$(e.target).parents('div[data-question-id]').find('.ays-field.ays-matching-field-option select option:selected').length;
2985                $(e.target).parents('div[data-question-id]').find('.ays-field.ays-matching-field-option').each( function ( index, item ) {
2986                    if( $(item).find( 'select.ays-select option[selected]' ).length > 0 ) {
2987                        answeredChoicesCount++;
2988                    }
2989                } );
2990            }
2991
2992            $(this).parent().find('.ays-select-field-value').attr("value", questionType === 'matching' ? choice : this_select_value);
2993            if($(this).parents(".ays-questions-container").find('form[id^="ays_finish_quiz"]').hasClass('enable_correction')) {
2994                var chishtPatasxan = $(this).find('option[selected="selected"]').data("chisht");
2995                var answerIsCorrect = chishtPatasxan == 1;
2996
2997                if( questionType === 'matching' ){
2998                    var answerId = $(this).parents('.ays-matching-field-match').data('answerId');
2999                    answerIsCorrect = Number( answerId ) === Number( choice );
3000                }
3001
3002                if (answerIsCorrect) {
3003                    if((right_answer_sound)){
3004                        resetPlaying([right_answer_sound, wrong_answer_sound]);
3005                        setTimeout(function(){
3006                            right_answer_sound.play();
3007                        }, 10);
3008                    }
3009                    $(this).parents('.ays-field').addClass('correct_div checked_answer_div');
3010                    $(this).parents('.ays-field').find('.select2-selection__rendered').css("background-color", "rgba(0, 128, 0, 0.6)");
3011                } else {
3012                    if((wrong_answer_sound)){
3013                        resetPlaying([right_answer_sound, wrong_answer_sound]);
3014                        setTimeout(function(){
3015                            wrong_answer_sound.play();
3016                        }, 10);
3017                    }
3018                    $(this).parents('.ays-field').addClass('wrong_div checked_answer_div');
3019                    $(this).parents('.ays-field').find('.select2-selection__rendered').css("background-color", "rgba(255, 2, 2, 0.6)");
3020                    if(showOnlyWrongAnswer === false){
3021                        var rightAnswerText = '<div class="ays-text-right-answer">';
3022
3023                        if ( questionType === 'matching' ) {
3024                            rightAnswerText += $(this).parents('.ays-matching-field-option').find('.ays-matching-field-choice').text();
3025                            rightAnswerText += ' -> ' + getObjectKey( thisAnswerOptions.question_answer, answerId, 'number' );
3026                        } else {
3027                            rightAnswerText += $(this).find('option[data-chisht="1"]').html();
3028                        }
3029
3030                        rightAnswerText += '</div>';
3031                        $(this).parents('.ays-quiz-answers').append(rightAnswerText);
3032                        $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').css("text-align", "left");
3033                        $(this).parents('.ays-quiz-answers').find('.ays-text-right-answer').slideDown(500);
3034                    }
3035                }
3036                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + questionId + '"]');
3037
3038                var isProcessToShowRWTexts = false;
3039                var isProcessToShowColors = false;
3040                var correctChoicesCount = $(e.target).parents('div[data-question-id]').find('.correct_div').length;
3041                var wrongChoicesCount = $(e.target).parents('div[data-question-id]').find('.wrong_div').length;
3042                var ifStatement = answerIsCorrect;
3043                if( questionType === 'matching' ) {
3044                    ifStatement = correctChoicesCount >= wrongChoicesCount;
3045                    answeredChoicesCount = $(e.target).parents('div[data-question-id]').find('.checked_answer_div').length;
3046                    if( choicesCount === answeredChoicesCount ) {
3047                        isProcessToShowRWTexts = true;
3048                        isProcessToShowColors = true;
3049                    }
3050                } else {
3051                    isProcessToShowColors = true;
3052                }
3053
3054                if (isProcessToShowColors){
3055                    if (ifStatement){
3056                        if( aysThisQuizBullets !== null ){
3057                            thisBullet.attr('disabled', 'disabled');
3058                            thisBullet.addClass('ays_quiz_correct_answer');
3059                            if (!thisBullet.parent().hasClass('ays-quiz-questions-nav-item-last-question')) {
3060                                thisBullet.parent().addClass('ays_quiz_checked_answer_div');
3061                            }
3062                        }
3063                    }else{
3064                        if( aysThisQuizBullets !== null ){
3065                            thisBullet.attr('disabled', 'disabled');
3066                            thisBullet.addClass('ays_quiz_wrong_answer');
3067                            if (!thisBullet.parent().hasClass('ays-quiz-questions-nav-item-last-question')) {
3068                                thisBullet.parent().addClass('ays_quiz_checked_answer_div');
3069                            }
3070                        }
3071                    }
3072                }
3073
3074                parentStep.removeClass('ays-has-error');
3075                thisBullet.removeClass('ays-has-error');
3076
3077                if ( questionType === 'matching' ) {
3078                    if ( isProcessToShowRWTexts === true ) {
3079                        if (myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both')) {
3080
3081                            if(checkbox_score_by){
3082                                if ( wrongChoicesCount > 0 ) {
3083                                    $(e.target).parents('div[data-question-id]').find('.wrong_answer_text').slideDown(500);
3084                                } else {
3085                                    $(e.target).parents('div[data-question-id]').find('.right_answer_text').slideDown(500);
3086                                }
3087                            } else {
3088                                if ( correctChoicesCount > wrongChoicesCount ) {
3089                                    $(e.target).parents('div[data-question-id]').find('.right_answer_text').slideDown(500);
3090                                } else {
3091                                    $(e.target).parents('div[data-question-id]').find('.wrong_answer_text').slideDown(500);
3092                                }
3093                            }
3094                        }
3095                    }
3096                } else {
3097                    if (myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both')) {
3098                        if (answerIsCorrect) {
3099                            $(e.target).parents('div[data-question-id]').find('.right_answer_text').slideDown(500);
3100                        } else {
3101                            $(e.target).parents('div[data-question-id]').find('.wrong_answer_text').slideDown(500);
3102                        }
3103                    }
3104                }
3105
3106                if(finishAfterWrongAnswer && ! answerIsCorrect ){
3107                    $(e.target).parents('div[data-question-id]').find('.ays_
3107next').attr('disabled', 'disabled');
3108                    $(e.target).parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled');
3109                    $(e.target).parents('div[data-question-id]').find('.ays_previous').attr('disabled', 'disabled');
3110                    if( disableQuestions ){
3111                        quizContainer.find('div[data-question-id]').css('pointer-events', 'none');
3112                    }
3113                    if( aysThisQuizBullets !== null ){
3114                        aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
3115                            var thisBullet = $(this);
3116                            thisBullet.attr('disabled', 'disabled');
3117                        });
3118                    }
3119                }
3120                if ( questionType !== 'matching' ) {
3121                    explanationTimeout = setTimeout(function () {
3122                        if (ifStatement) {
3123                            if ($(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
3124                                $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
3125                                $(e.target).parents('div[data-question-id]').find('.ays_next').trigger('click');
3126                            } else if (quiz_display_all_questions && isRequiredQuestion && !enableNextButton) {
3127                                var existsEmtpyQuestions = ays_quiz_is_question_empty(quizContainer.find('div[data-question-id]'));
3128                                if (existsEmtpyQuestions) {
3129                                    if (infoFormLast.length == 0) {
3130                                        quizContainer.find('input.ays_finish').trigger('click');
3131                                    } else {
3132                                        quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
3133                                    }
3134                                }
3135                            }
3136                        } else {
3137                            if (finishAfterWrongAnswer) {
3138                                window.aysEarlyFinishConfirmBox[quizId] = true;
3139                                goToLastPage(e);
3140                            } else {
3141                                if ($(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
3142                                    $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
3143                                    $(e.target).parents('div[data-question-id]').find('.ays_next').trigger('click');
3144                                } else if (quiz_display_all_questions && isRequiredQuestion && !enableNextButton) {
3145                                    var existsEmtpyQuestions = ays_quiz_is_question_empty(quizContainer.find('div[data-question-id]'));
3146                                    if (existsEmtpyQuestions) {
3147                                        if (infoFormLast.length == 0) {
3148                                            quizContainer.find('input.ays_finish').trigger('click');
3149                                        } else {
3150                                            quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
3151                                        }
3152                                    }
3153                                }
3154                            }
3155                        }
3156                    }, explanationTime * 1000);
3157
3158                    if (quizWaitingTime && !quizNextButton) {
3159                        window.countdownTimeForShowInterval = setInterval(function () {
3160                            countdownTimeForShow( parentStep, quizWaitingCountDownDate );
3161                        }, 1000);
3162                    }
3163                }
3164
3165                var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page";
3166                if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){
3167                    if ( questionType === 'matching' ) {
3168                        if (isProcessToShowRWTexts === true) {
3169                            if (!$(this).parents('.step').hasClass('not_influence_to_score')) {
3170                                $(this).parents('.step').find('.ays_questtion_explanation').slideDown(250);
3171                            }
3172                        }
3173                    }else {
3174                        if (!$(this).parents('.step').hasClass('not_influence_to_score')) {
3175                            $(this).parents('.step').find('.ays_questtion_explanation').slideDown(250);
3176                        }
3177                    }
3178                }
3179                $(this).attr("disabled", true);
3180
3181                if ( isProcessToShowColors ) {
3182                    stopQuestionTimer(quizContainer, questionId, quizId);
3183                }
3184            }else{
3185                if ($(this).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
3186                    $(this).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
3187                    $(this).parents('div[data-question-id]').find('.ays_
3187next').trigger('click');
3188                }
3189                var bulletsStatement = $(this).find('option:selected').length !== 0;
3190                if ( questionType === 'matching' ) {
3191                    bulletsStatement = answeredChoicesCount === choicesCount;
3192                }
3193
3194                if( bulletsStatement ){
3195                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + questionId + '"]');
3196                    thisBullet.parents('.ays-quiz-questions-nav-item').addClass('ays-quiz-questions-nav-item-answered');
3197                }else{
3198                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + questionId + '"]');
3199                    thisBullet.parents('.ays-quiz-questions-nav-item').removeClass('ays-quiz-questions-nav-item-answered');
3200                }
3201
3202            }
3203
3204            if(isRequiredQuestion === true){
3205                var buttonsStatement = $(this).find('option:selected').length !== 0;
3206                if ( questionType === 'matching' ) {
3207                    buttonsStatement = answeredChoicesCount === choicesCount;
3208                }
3209
3210                if( buttonsStatement ){
3211                    if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
3212                        $(e.target).parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
3213                        $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
3214                    }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
3215                        $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
3216                        $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
3217                    }
3218                }else{
3219                    if (!$(e.target).parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
3220                        $(e.target).parents('div[data-question-id]').find('input.ays_next').attr('disabled', true);
3221                        $(e.target).parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true);
3222                    }else if(!$(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
3223                        $(e.target).parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true);
3224                        $(e.target).parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true);
3225                    }
3226                }
3227            }
3228
3229            // $(this).find("option").removeAttr("selected");
3230            // $(this).find("option[value='"+this_select_value+"']").attr("selected", true);
3231        });
3232
3233        function aysSelectDropdownCheck(select){
3234            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
3235            if(isRequiredQuestion === true){
3236                if(select.val() != ''){
3237                    if (!select.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
3238                        select.parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
3239                        select.parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
3240                    }else if(!select.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
3241                        select.parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
3242                        select.parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
3243                    }
3244                }else{
3245                    if (!select.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
3246                        select.parents('div[data-question-id]').find('input.ays_next').attr('disabled', true);
3247                        select.parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', true);
3248                    }else if(!select.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
3249                        select.parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', true);
3250                        select.parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', true);
3251                    }
3252                }
3253            }
3254        }
3255
3256        // var shareButtons = document.querySelectorAll(".ays-share-btn.ays-to-share");
3257        $(document).on('click', ".ays-share-btn.ays-to-share", function (event){
3258            var width = 650,
3259                height = 450;
3260
3261            event.preventDefault();
3262
3263            window.open(this.href, quizLangObj.shareDialog, 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+width+',height='+height+',top='+(screen.height/2-height/2)+',left='+(screen.width/2-width/2));
3264        });
3265
3266        // if (shareButtons) {
3267        //     [].forEach.call(shareButtons, function(button) {
3268        //         button.addEventListener("click", function(event) {
3269        //             var width = 650,
3270        //                 height = 450;
3271
3272        //             event.preventDefault();
3273
3274        //             window.open(this.href, quizLangObj.shareDialog, 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+width+',height='+height+',top='+(screen.height/2-height/2)+',left='+(screen.width/2-width/2));
3275        //         });
3276        //     });
3277        // }
3278
3279        $(document).find('.ays-quiz-container').map(function () {
3280            $(this).find('div[data-question-id]').eq(0).find('.ays_previous').css({'display':'none'});
3281            var next_sibilings_count = parseInt($(this).find('.ays_question_count_per_page').val());
3282            if(next_sibilings_count>0){
3283                $(this).find('div[data-question-id]').eq(next_sibilings_count-1).find('.ays_previous').css({'display':'none'});
3284            }
3285        });
3286
3287        $(document).on('click', '.ays_finish.action-button.ays_arrow', function () {
3288            $(this).parents('.ays_buttons_div').find('input.ays_next.action-button').trigger('click');
3289        });
3290
3291        $(document).find('div[data-question-id]').map(function () {
3292            $(this).find('.ays-quiz-answers .ays-field').map(function () {
3293                if($(this).find('label[for^="ays-answer"]').eq(1).find('img').length !== 0){
3294                    $(this).find('label[for^="ays-answer"]').eq(0).addClass('ays_empty_before_content');
3295                    if($(this).find('label[for^="ays-answer"]').eq(0).text().length === 0){
3296                        $(this).find('label[for^="ays-answer"]').eq(0).css('background','transparent');
3297                    }
3298                }
3299            });
3300        });
3301        
3302        $(document).on('click', '.ays_finish.action-button', function () {
3303            var quizId = $(this).parents(".ays-quiz-container").find('input[name="ays_quiz_id"]').val();
3304            if ( typeof window.aysEarlyFinishConfirmBox != 'undefined') {
3305                if ( typeof window.aysEarlyFinishConfirmBox[ quizId ] != 'undefined' ) {
3306                    if( window.aysSeeResultConfirmBox[ quizId ] == true ){
3307                        $(this).addClass("ays_timer_end");
3308                    }
3309                }
3310            }
3311            if (typeof $(this).parents('.ays-quiz-container').find('.ays_
3311next.start_button').attr("data-enable-leave-page") !== 'undefined') {
3312                if(! $(this).parents('.ays-quiz-container').find('.step.active-step .ays-abs-fs.ays-end-page').hasClass('information_form')){
3313                    $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page",false);
3314                }
3315            }
3316        });
3317        
3318        $(document).on('click', '.ays_early_finish.action-button', function (e) {
3319            e.preventDefault();
3320            var quizId = $(this).parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
3321
3322            if (typeof $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page") !== 'undefined') {
3323                if(! $(this).parents('.ays-quiz-container').find('.step .ays-abs-fs.ays-end-page').hasClass('information_form')){
3324                    $(this).parents('.ays-quiz-container').find('.ays_next.start_button').attr("data-enable-leave-page",false);
3325                }
3326            }
3327            var confirm;
3328            if (myOptions.enable_early_finsh_comfirm_box && myOptions.enable_early_finsh_comfirm_box == "off") {
3329                confirm = true;
3330            }else{
3331                confirm = window.confirm(quizLangObj.areYouSure);
3332            }
3333            if(confirm){
3334                clearTimeout(explanationTimeout);
3335                window.aysEarlyFinishConfirmBox[ quizId ] = true;
3336                var totalSteps = $(e.target).parents().eq(3).find('div.step').length;
3337                var currentStep = $(e.target).parents().eq(3).find('div.step.active-step');
3338                var thankYouStep = $(e.target).parents().eq(3).find('div.step.ays_thank_you_fs');
3339                var infoFormLast = thankYouStep.prev().find('div.information_form');
3340                var questions_count = $(e.target).parents('form.ays-quiz-form').find('div[data-question-id]').length;
3341                $(this).parents('.ays-quiz-container').find('.ays_finish.action-button').addClass("ays_timer_end");
3342                if($(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
3343                    $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(questions_count);
3344                }else{
3345                    $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-fill').animate({
3346                        width: '100%'
3347                    });
3348                    $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-percent').text(100);
3349                }
3350                currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').slideUp();
3351                setTimeout(function () {
3352                    currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide();
3353                },300);
3354                if(infoFormLast.length == 0){
3355                    if (currentStep.hasClass('ays_thank_you_fs') === false) {
3356                        var steps = totalSteps - 3;
3357                        $(e.target).parents().eq(3).find('div.step').each(function (index) {
3358                            if ($(this).hasClass('ays_thank_you_fs')) {
3359                                $(this).addClass('active-step')
3360                            }else{
3361                                $(this).css('display', 'none');
3362                            }
3363                        });
3364                        $(e.target).parents().eq(3).find('input.ays_finish').trigger('click');
3365                    }
3366                }else{
3367                    currentStep.parents('.ays-quiz-container').find('.ays-quiz-timer').parent().hide();
3368                    $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
3369                    setTimeout(function () {
3370                        $(e.target).parents('.ays-quiz-container').find('.ays-live-bar-wrap').css('display','none');
3371                    },300);
3372                    aysAnimateStep($(e.target).parents('.ays-quiz-container').data('quest-effect'), currentStep, infoFormLast.parent());
3373                    $(e.target).parents().eq(3).find('div.step').each(function (index) {
3374                        $(this).css('display', 'none');
3375                        $(this).removeClass('active-step')
3376                    });
3377                    infoFormLast.parent().css('display', 'flex');
3378                    infoFormLast.parent().addClass('active-step');
3379                    
3380                    $(this).parents(".ays-quiz-container").find('.ays_finish.action-button').addClass("ays_timer_end");
3381                    $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slide
3381Up(500);
3382                }
3383
3384                if( $(this).parents('.ays-questions-container').length > 0 ){
3385                    if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top || $(this).parents('.ays-questions-container').offset().top > 500){
3386                        $(this).parents(".ays-quiz-container").goTo( myOptions );
3387                    }
3388                }
3389            }
3390        });
3391
3392        $(document).on('click', '.action-button.ays_restart_training_button', function () {
3393            window.location.href = window.location.href + ( window.location.search ? '&' : '?' ) + 'reset_quiz=1';
3394        });
3395
3396        $(document).on('click', '.action-button.ays_restart_button', function () {
3397            // if (window.location != window.parent.location) {
3398            //     parent.location.reload();
3399            // } else {
3400                window.location.reload();
3401            // }
3402        });
3403
3404        $(document).on('click', '.action-button.ays-quiz-exit-button', function (e) {
3405            if (window.location != window.parent.location) {
3406                var ays_quiz_exit_url = $(this).attr('href');
3407                if ( typeof ays_quiz_exit_url != "undefined" && ays_quiz_exit_url != "" ) {
3408                    e.preventDefault();
3409                    parent.location = ays_quiz_exit_url;
3410                }
3411            }
3412        });
3413        
3414        $(document).on('click', '.action-button.ays_clear_answer', function () {
3415            var $this = $(this);
3416            var activeStep = $this.parents('.step');
3417            var inputs = activeStep.find('input[name^="ays_questions[ays-question-"]:checked');
3418            var checked_answer_divs = activeStep.find('div.ays-field.checked_answer_div');
3419            var ays_text_field = activeStep.find('div.ays-field.ays-text-field');
3420            var ays_select_field = activeStep.find('div.ays-field.ays-select-field, div.ays-matching-field');
3421            inputs.removeAttr('checked');
3422            inputs.prop('checked', false);
3423            if (myOptions.make_questions_required && myOptions.make_questions_required == "on") {
3424                inputs.trigger('change');
3425            }
3426            // inputs.trigger('change');
3427            checked_answer_divs.removeClass('checked_answer_div');
3428            ays_text_field.find('.ays-text-input').val('');
3429            ays_text_field.find('.ays-text-input').trigger('input');
3430            if(ays_select_field.find('select.ays-select').length > 0){
3431                ays_select_field.find('select.ays-select').val(null).trigger('change');
3432                ays_select_field.find('select.ays-select option').removeAttr('selected');
3433                var thisQuestionID = ays_select_field.parents('div[data-question-id]').data('questionId');
3434                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
3435                thisBullet.parents('.ays-quiz-questions-nav-item').removeClass('ays-quiz-questions-nav-item-answered');
3436                aysSelectDropdownCheck(ays_select_field.find('select.ays-select'));
3437            }
3438        });
3439        
3440        $(document).on('click', '.ays_music_sound', function() {
3441            var $this = $(this);
3442            var quizCoutainer = $this.parents('.ays-quiz-container');
3443            var audioEls = $(document).find('audio.ays_quiz_music');
3444            var soundEls = $(document).find('.ays_music_sound');
3445            var audioEl = quizCoutainer.find('audio.ays_quiz_music').get(0);
3446            if($this.hasClass('ays_sound_active')){
3447                audioEl.volume = 0;
3448                $this.find('.ays_fa').addClass('ays_fa_volume_off').removeClass('ays_fa_volume_up');
3449                $this.removeClass('ays_sound_active');
3450            } else {
3451                audioEl.volume = 1;
3452                $this.find('.ays_fa').addClass('ays_fa_volume_up').removeClass('ays_fa_volume_off');
3453                $this.addClass('ays_sound_active');
3454            }
3455        });
3456
3457        function goToLastPage(e){
3458            clearTimeout(explanationTimeout);
3459            clearInterval(window.aysTimerInterval);
3460            var container = $(e.target).parents('.ays-quiz-container');
3461            var totalSteps = container.find('div.step').length;
3462            var currentStep = container.find('div.step.active-step');
3463            var thankYouStep = container.find('div.step.ays_thank_you_fs');
3464            var infoFormLast = thankYouStep.prev().find('div.information_form');
3465            var questions_count = $(e.target).parents('form.ays-quiz-form').find('div[data-question-id]').length;
3466            if(container.find('.ays-live-bar-percent').hasClass('ays-live-bar-count')){
3467                container.find('.ays-live-bar-percent').text(questions_count);
3468            }else{
3469                container.find('.ays-live-bar-fill').animate({
3470                    width: '100%'
3471                });
3472                container.find('.ays-live-bar-percent').text(100);
3473            }
3474            container.find('.ays-quiz-timer').slideUp();
3475            setTimeout(function () {
3476                container.find('.ays-quiz-timer').parent().hide();
3477            },300);
3478
3479            if(infoFormLast.length == 0){
3480                if (currentStep.hasClass('ays_thank_you_fs') === false) {
3481                    var steps = totalSteps - 3;
3482                    container.find('div.step').each(function (index) {
3483                        if ($(this).hasClass('ays_thank_you_fs')) {
3484                            $(this).addClass('active-step')
3485                        }else{
3486                            $(this).css('display', 'none');
3487                        }
3488                    });
3489                    container.find('input.ays_finish').trigger('click');
3490                }
3491            }else{
3492                container.find('.ays-quiz-timer').parent().hide();
3493                container.find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
3494                setTimeout(function () {
3495                    container.find('.ays-live-bar-wrap').css('display','none');
3496                },300);
3497                aysAnimateStep(container.data('quest-effect'), currentStep, infoFormLast.parent());
3498                container.find('div.step').each(function (index) {
3499                    $(this).css('display', 'none');
3500                    $(this).removeClass('active-step')
3501                });
3502                infoFormLast.parent().css('display', 'flex');
3503                infoFormLast.parent().addClass('active-step');
3504
3505                $(e.target).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slide
3505Up(500);
3506            }
3507        }
3508
3509        function ays_formatState (ays_state) {
3510            if(!ays_state.id) {
3511                return aysEscapeHtml(ays_state.text);
3512            }
3513            var baseUrl = $(ays_state.element).data('nkar');
3514            if(baseUrl != ''){
3515                var ays_state = $(
3516                    '<span><img src=' + baseUrl + ' class="ays_answer_select_image" /> ' + aysEscapeHtml(ays_state.text) + '</span>'
3517                );
3518            }else{
3519                var ays_state = $('<span>' + aysEscapeHtml(ays_state.text) + '</span>');
3520            }
3521            return ays_state;
3522        }
3523
3524        $(document).find('.ays-quiz-container').each(function(){
3525            var $this = $(this);
3526            var selectEl = $this.find('select.ays-select');
3527            selectEl.each(function(){
3528                $(this).select2({
3529                    placeholder: quizLangObj.selectPlaceholder,
3530                    dropdownParent: $(this).parents('.ays-abs-fs'),
3531                    templateResult: ays_formatState
3532                });
3533            });
3534        });
3535
3536        $(document).find('.ays-quiz-container b[role="presentation"]').addClass('ays_fa ays_fa_chevron_down');
3537
3538        function aysResetQuiz ($quizContainer){
3539            var cont = $quizContainer.find('div[data-question-id]');
3540            cont.find('input[type="text"], textarea, input[type="number"], input[type="url"], input[type="email"]').each(function(){
3541                $(this).val('');
3542            });
3543            cont.find('select').each(function(){
3544                $(this).val('');
3545            });
3546            cont.find('select.ays-select').each(function(){
3547                $(this).val(null).trigger('change');
3548            });
3549            cont.find('select option').each(function(){
3550                $(this).removeAttr('selected');
3551            });
3552            cont.find('input[type="radio"], input[type="checkbox"]').each(function(){
3553                $(this).removeAttr('checked');
3554            });
3555        }
3556
3557        window.addEventListener("beforeunload", function (e) {
3558            var startButton = $(document).find('.ays-quiz-container .ays_next.start_button');
3559            var flag = false;
3560            for (var i = 0; i < startButton.length; i++) {
3561                var startBtn = startButton.eq(i).attr('data-enable-leave-page');
3562                if(typeof startBtn != undefined && startBtn === 'true'){
3563                    flag = true;
3564                    break;
3565                }
3566            }
3567
3568            if(flag){
3569                event.preventDefault();
3570                speechSynthesis.cancel();
3571                return true;
3572            }else{
3573                return null;
3574            }
3575        });
3576
3577        window.onbeforeunload =  function (e) {
3578            var startButton = $(document).find('.ays-quiz-container .ays_next.start_button');
3579            var flag = false;
3580            for (var i = 0; i < startButton.length; i++) {
3581                var startBtn = startButton.eq(i).attr('data-enable-leave-page');
3582                if(typeof startBtn != undefined && startBtn === 'true'){
3583                    flag = true;
3584                    break;
3585                }
3586            }
3587            if(flag){
3588                event.preventDefault();
3589                speechSynthesis.cancel();
3590                return true;
3591            }else{
3592                return null;
3593            }
3594        }
3595
3596        if( $(document).find('.ays-quiz-container').length > 0 ){
3597            var ays_quiz_autostart_interval = setInterval( function() {
3598                if (document.readyState === 'complete') {
3599                    var firstQuiz = $(document).find('.ays-quiz-container').first();
3600                    if( firstQuiz.find('input[name="ays_quiz_id"]').length > 0 ){
3601                        var fisrtQuizId = firstQuiz.find('input[name="ays_quiz_id"]').val();
3602                        var fisrtQuizOptions = JSON.parse(atob(window.aysQuizOptions[fisrtQuizId]));
3603
3604                        var questions_count = firstQuiz.find('div[data-question-id]').length;
3605
3606                        if(typeof fisrtQuizOptions.enable_autostart == 'undefined'){
3607                            fisrtQuizOptions.enable_autostart = 'off';
3608                        }
3609
3610                        if(typeof fisrtQuizOptions.enable_password == 'undefined'){
3611                            fisrtQuizOptions.enable_password = 'off';
3612                        }
3613
3614                        if( fisrtQuizOptions.enable_autostart == 'on' && fisrtQuizOptions.enable_password == 'off' ){
3615                            if ( questions_count > 0 ) {
3616                                var quizFirstPage = firstQuiz.find(".ays-questions-container div.step").first();
3617
3618                                if( quizFirstPage.hasClass('active-step') ){
3619                                    if(quizFirstPage.find('.ays_buttons_div .ays_next.start_button').length > 0 ){
3620                                        setTimeout(function(){
3621                                            firstQuiz.find('.ays_
3621next.start_button').trigger('click');
3622                                        }, 500);
3623                                    }
3624                                }
3625                            }
3626
3627                        }
3628                    }
3629                    clearInterval(ays_quiz_autostart_interval);
3630                }
3631            }, 500);
3632        }
3633
3634        $(document).find('.ays_next.start_button.ays_quiz_enable_loader').each(function(e){
3635            var $this = $(this);
3636            var container = $(this).parents('.ays-quiz-container');
3637
3638            var ays_quiz = setInterval( function() {
3639                if (document.readyState === 'complete') {
3640                    var startButtonText = quizLangObj.startButtonText;
3641                    if (startButtonText == null || startButtonText == '' ) {
3642                        startButtonText = quizLangObj.defaultStartButtonText;
3643                    }
3644
3645                    container.find('.ays_quiz_start_button_loader_container').addClass('ays_display_none');
3646                    if ( $this.hasClass('ays_quiz_enable_loader') ) {
3647                        $this.removeClass('ays_quiz_enable_loader');
3648                    }
3649                    $this.prop('disabled', false);
3650                    $this.val( startButtonText );
3651                    clearInterval(ays_quiz);
3652                }
3653            }, 500);
3654        });
3655
3656        $(document).find('.show_timer_countdown').each(function(e){
3657            // Countdown date
3658            var countDownEndDate = $(this).data('timer_countdown');
3659            var quiz_id = $(this).parents(".ays-quiz-container").attr("id");
3660            if (countDownEndDate != '' && countDownEndDate != undefined) {
3661                var showM = $(this).parents('.step').data('messageExist');
3662                ays_countdown_datetime(countDownEndDate, !showM, quiz_id);
3663            }
3664        });
3665
3666        document.addEventListener('fullscreenchange', function(event) {
3667            if (!document.fullscreenElement) {
3668                var eventTarget = event.target
3669                if( $( eventTarget ).hasClass('ays-quiz-container') ){
3670                    aysQuizFullScreenDeactivate( eventTarget );
3671                }
3672            }
3673        }, false);
3674
3675        $(document).on('click', '.ays-quiz-open-full-screen, .ays-quiz-close-full-screen', function() {
3676            var quiz_container = $(this).parents('.ays-quiz-container').get(0);
3677            toggleFullscreen(quiz_container);
3678        });
3679
3680        $(document).on('click', '.action-button.ays_chain_next_quiz_button', function () {
3681            if (window.location != window.parent.location) {
3682                parent.location.reload();
3683            } else {
3684                window.location.reload();
3685            }
3686        });
3687
3688        $(document).on('click', '.action-button.ays_chain_see_result_button', function () {
3689            if (window.location != window.parent.location) {
3690                parent.location.reload();
3691            } else {
3692                window.location.reload();
3693            }
3694        });
3695
3696        $(document).on('change', '.ays-quiz-res-toggle-checkbox', function(){
3697            var _this  = $(this);
3698            var parent = _this.parents('.ays_quiz_results');
3699            var elements = parent.find('.step.ays_question_result');
3700
3701            if (_this.prop('checked')) {
3702                if (  elements.hasClass('ays_display_none') ) {
3703                    elements.removeClass('ays_display_none');
3704                }
3705            }else{
3706                elements.addClass('ays_display_none');             
3707            }
3708        });
3709
3710        $(document).on('keydown', function(e) {
3711            var keyboardBox = $(document).find(".ays-quiz-container.ays-quiz-keyboard-active");
3712
3713            if(e.keyCode === 9 && keyboardBox.length > 0){
3714                $(document).find(".ays-select-field *:not(.dropdown-wrapper,.select2-selection__arrow, .select2-selection__placeholder, .ays_fa.ays_fa_chevron_down)").attr("tabindex" , "0")
3715            }
3716
3717            if(e.keyCode === 27){
3718                var zoomPopup = $(document).find('.ays-quiz-question-image-lightbox-container');
3719                if( zoomPopup.length > 0 ){
3720                    zoomPopup.hide();
3721                }
3722
3723                var questionReportPopup = $(document).find('div[id*="ays-quiz-question-report-modal"]');
3724                if( questionReportPopup.length > 0 ){
3725                    questionReportPopup.hide();
3726                }
3727            }
3728
3729            if($(e.target).hasClass("ays-quiz-keyboard-active")){
3730                if (e.keyCode === 32) {
3731                    e.preventDefault();
3732                    $(e.target).find('label.ays-quiz-keyboard-label').trigger("click");
3733                }
3734
3735
3736                if (e.keyCode === 13) {
3737                    e.preventDefault();
3738                    var checked_inputs = $(e.target).parents(".ays-quiz-answers").find('input
3738:checked');
3739                    if(checked_inputs.length > 0){
3740                        $(e.target).parents('.step.active-step').find(".ays_next").trigger('click');
3741                    }
3742                    else{
3743                        $(e.target).trigger('click');
3744                    }
3745
3746                }
3747            }
3748        });
3749
3750        $(document).on('click', '.ays-image-question-img .ays-quiz-question-image-zoom', function(e) {
3751            var _this = $(this);
3752
3753            var dataSrc = _this.attr('data-ays-src');
3754            var keyboardBox = _this.parents(".ays-quiz-container.ays-quiz-keyboard-active");
3755            var keyboardClass = "";
3756            var keyboardTabindex = "";
3757
3758            if(keyboardBox.length > 0){
3759                keyboardClass = "ays-quiz-keyboard-active";
3760                keyboardTabindex = "tabindex='0'";
3761            }
3762
3763            if (dataSrc != null && dataSrc != "") {
3764                var aysImagesOverlayBox = $(document).find('.ays-quiz-question-image-lightbox-container');
3765                var lightboxContainer = "";
3766                if (aysImagesOverlayBox.length > 0 )  {
3767                    var mainDiv = document.querySelector(".ays-quiz-question-image-lightbox-container");
3768                    var createdImgTag = document.querySelector(".ays-quiz-question-image-lightbox-img");
3769
3770                    createdImgTag.src = dataSrc;
3771                    mainDiv.style.display = "flex";
3772                } else {
3773                    var bodyTag = document.getElementsByTagName("body")[0];
3774
3775                    lightboxContainer += '<div class="ays-quiz-question-image-lightbox-container" style="display: flex;">';
3776
3777                        lightboxContainer += '<div class="ays-quiz-question-image-lightbox-img-box">';
3778                            lightboxContainer += '<img class="ays-quiz-question-image-lightbox-img" src="'+ dataSrc +'" style="z-index: 102;">';
3779                        lightboxContainer += '</div>';
3780                        lightboxContainer += '<span class="ays-quiz-question-image-lightbox-close-button '+ keyboardClass +'" '+ keyboardTabindex +'>×</span>';
3781
3782                    lightboxContainer += '</div>';
3783
3784                    $(document).find('html > body').append(lightboxContainer);
3785
3786                    var mainDiv = $(document).find(".ays-quiz-question-image-lightbox-container");
3787                    mainDiv.css({
3788                        'display': 'flex'
3789                    });
3790                }
3791            }
3792        });
3793
3794
3795        $(document).on('click', '.ays-quiz-question-image-lightbox-close-button', function() {
3796            var _this = $(this);
3797            var parent = _this.parents(".ays-quiz-question-image-lightbox-container");
3798
3799            parent.css({
3800                'display': 'none'
3801            });
3802        });
3803
3804        $(document).on('click', '.ays-quiz-question-image-lightbox-container', function(e){
3805            var modalBox = $(e.target).attr('class');
3806            var _this = $(this);
3807
3808            if (typeof modalBox != 'undefined' &&  modalBox == 'ays-quiz-question-image-lightbox-container') {
3809                _this.css({
3810                    'display': 'none'
3811                });
3812            }
3813        });
3814
3815        $(document).on('click', '.ays-navbar-bookmark', function(e) {
3816            var _this = $(this);
3817            var parent = _this.parents('div.ays-quiz-container');
3818            var highlighted = ($(this).attr('highlighted') === 'true');
3819            var navbarItem = parent.find('.ays-quiz-questions-nav-wrap .ays-quiz-questions-nav-item-active');
3820            var src = $(this).attr('src');
3821
3822            if (!highlighted) {
3823                $(this).attr('highlighted', true).attr('src', src.replace('empty', 'filled'));
3824                navbarItem.find('.ays-quiz-navbar-highlighted-notice').show();
3825            } else {
3826                $(this).attr('highlighted', false).attr('src', src.replace('filled', 'empty'));
3827                navbarItem.find('.ays-quiz-navbar-highlighted-notice').hide();
3828            }
3829        });
3830
3831        $(document).on('click', '.ays-quiz-open-report-window', function() {
3832            var _this = $(this);
3833            var parent = _this.parents('div.ays-quiz-container');
3834
3835            if (_this.parents('div.step.active-step').length > 0) {
3836                var question = _this.parents('div.step.active-step');
3837            } else {
3838                var question = _this.parents('div.step.ays_question_result');
3839
3840            }
3841
3842            if( question.length == 0 ){
3843                var question = _this.parents('div.step');
3844            }
3845
3846            var questionId = question.attr('data-question-id');
3847
3848            var reportsModal = parent.find('div.ays-modal-reports');
3849
3850            reportsModal.fadeIn(200, function() {
3851                reportsModal.find('textarea#ays-quiz-question-report-textarea').val('');
3852                reportsModal.find('input.ays-quiz-report-question-id').val(questionId);
3853            });
3854        });
3855        
3856        $(document).find('.ays-close-reports-window').on('click', function() {
3857            var _this = $(this);
3858            var parent = _this.parents('div.ays-quiz-container');
3859            var reportsModal = parent.find('div.ays-modal-reports');
3860
3861            reportsModal.fadeOut(200);
3862        });
3863
3864        $(document).on('keypress', '.ays_quiz_form_input_number_type', function(e) {
3865            if( navigator.userAgent.toLowerCase().includes('firefox') ){
3866                return e.charCode >= 48 && e.charCode <= 57;
3867            }
3868        });
3869
3870        function quizTimer( container ){
3871            container.find('div.ays-quiz-timer').hide(800);
3872            var timer = parseInt(container.find('div.ays-quiz-timer').attr('data-timer'));
3873            var pageTitle = $(document).find('title');
3874            var pageTitleText = $(document).find('title').html();
3875            var timeForShow = "";
3876
3877            // Display all questions on one page
3878            myOptions.quiz_timer_red_warning = ( myOptions.quiz_timer_red_warning ) ? myOptions.quiz_timer_red_warning : 'off';
3879            var quiz_timer_red_warning = (myOptions.quiz_timer_red_warning && myOptions.quiz_timer_red_warning == "on") ? true : false;
3880
3881            if (!isNaN(timer) && myOptions.timer !== undefined) {
3882                if (myOptions.timer === timer && timer !== 0) {
3883                    timer += 2;
3884                    if (timer !== undefined) {
3885                        var countDownDate = new Date().getTime() + (timer * 1000);
3886                        var timerFlag = false;
3887
3888                        // Message before timer
3889                        var quiz_message_before_timer = (myOptions.quiz_message_before_timer && myOptions.quiz_message_before_timer != "") ? ( myOptions.quiz_message_before_timer ) : '';
3890
3891                        if ( quiz_message_before_timer != '' ) {
3892                            quiz_message_before_timer = quiz_message_before_timer.replace(/(["'])/g, "\\$1") + " ";
3893                            $(document).find('html > head').append('<style> #ays-quiz-container-'+ quizId +' div.ays-quiz-timer.ays-quiz-message-before-timer:before{content: "'+ quiz_message_before_timer +'"; }</style>');
3894                        }
3895
3896                        window.aysTimerInterval = setInterval(function () {
3897                            var now = new Date().getTime();
3898                            var distance = countDownDate - Math.ceil(now/1000)*1000;
3899                            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
3900                            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
3901                            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
3902                            var sec = seconds;
3903                            var min = minutes;
3904                            var hour = hours;
3905                            if(hours <= 0){
3906                                hours = null;
3907                            }else if (hours < 10) {
3908                                hours = '0' + hours;
3909                            }
3910                            if (minutes < 10) {
3911                                minutes = '0' + minutes;
3912                            }
3913                            if (seconds < 10) {
3914                                seconds = '0' + seconds;
3915                            }
3916                            timeForShow =  ((hours==null)? "" : (hours + ":")) + minutes + ":" + seconds;
3917                            if(distance <=1000){
3918                                timeForShow =  ((hours==null) ? "" : "00:") + "00:00";
3919                                container.find('div.ays-quiz-timer').html(timeForShow);
3920                                if(myOptions.quiz_timer_in_title == 'on'){
3921                                    pageTitle.html( timeForShow + " - " + pageTitleText );
3922                                }
3923                            }else{
3924                                container.find('div.ays-quiz-timer').html(timeForShow);
3925                                if(myOptions.quiz_timer_in_title == 'on'){
3926                                    pageTitle.html( timeForShow + " - " + pageTitleText );
3927                                }
3928                            }
3929
3930                            if ( quiz_timer_red_warning ) {
3931                                var distanceSec = Math.floor(distance / 1000);
3932                                var timerPercentage = Math.floor(( timer - distanceSec ) * 100);
3933                                var percentage = Math.floor( timerPercentage / timer );
3934
3935                                if ( percentage >= 90 && ! timerFlag ) {
3936                                    var timerContainer = container.find('section.ays_quiz_timer_container');
3937                                    timerFlag = true;
3938
3939                                    if ( ! timerContainer.hasClass( 'ays_quiz_timer_red_warning' ) ) {
3940                                        timerContainer.addClass( 'ays_quiz_timer_red_warning' );
3941                                    }
3942                                }
3943                            }
3944
3945                            container.find('.ays_quiz_timer_container').show();
3946                            container.find('div.ays-quiz-timer').show(500);
3947                            if(container.find('.ays-quiz-timer').length === 0){
3948                                clearInterval(window.aysTimerInterval);
3949                                if(myOptions.quiz_timer_in_title == 'on'){
3950                                    pageTitle.html( pageTitleText );
3951                                }
3952                                container.find('.ays_quiz_timer_container').slideUp(500);
3953                            }
3954                            if(container.find('.ays_finish.action-button').hasClass("ays_timer_end") ||
3955                                container.find('.ays_next.action-button').hasClass("ays_timer_end")){
3956                                clearInterval(window.aysTimerInterval);
3957                                if(myOptions.quiz_timer_in_title == 'on'){
3958                                    pageTitle.html( pageTitleText );
3959                                }
3960                                container.find('.ays_quiz_timer_container').slideUp(500);
3961                            }
3962
3963                            if(hour == 0 && min == 0 && sec < 1){
3964                                container.find('.ays_buttons_div > *:not(input.ays_finish)').off('click');
3965                            }
3966
3967                            if (distance <= 1) {
3968                                clearInterval(window.aysTimerInterval);
3969                                if(! container.find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){
3970                                    container.find('.ays_quiz_timer_container').css({
3971                                        'position': 'static',
3972                                        'height': '100%',
3973                                    });
3974                                    container.find('.ays_quiz_timer_container').show();
3975                                    container.find('div.ays-quiz-timer').slideUp();
3976                                    container.find('div.ays-quiz-after-timer').addClass("ays-quiz-timer-end");
3977                                    container.find('.ays_quiz_timer_container').addClass("ays-quiz-timer-end-for-required");
3978                                    container.find('div.ays-quiz-after-timer').slideDown(500);
3979                                }else{
3980                                    container.find('.ays_quiz_timer_container').slideUp(500);
3981                                    container.find('.ays_quiz_timer_container').addClass("ays-quiz-timer-end-for-required");
3982                                }
3983
3984                                if(myOptions.quiz_timer_in_title == 'on'){
3985                                    pageTitle.html( pageTitleText );
3986                                }
3987                                var totalSteps = container.find('div.step').length;
3988                                var currentStep = container.find('div.step.active-step');
3989                                var thankYouStep = container.find('div.step.ays_thank_you_fs');
3990                                var infoFormLast = thankYouStep.prev().find('div.information_form');
3991
3992                                var myStartDate = new Date(Date.now() - aysDurationInSeconds * AYS_MS_PER_SECONDS);
3993                                var countdownEndTime = myStartDate.aysCustomFormat( "#YYYY#-#MM#-#DD# #hhhh#:#mm#:#ss#" );
3994
3995                                container.find('input.ays-quiz-end-date').val(countdownEndTime);
3996                                if(infoFormLast.length == 0){
3997                                    if (currentStep.hasClass('ays_thank_you_fs') === false) {
3998                                        var steps = totalSteps - 3;
3999                                        container.find('div.step').each(function (index) {
4000                                            if ($(this).hasClass('ays_thank_you_fs')) {
4001                                                $(this).addClass('active-step')
4002                                            }else{
4003                                                $(this).css('display', 'none');
4004                                            }
4005                                        });
4006                                        // aysAnimateStep(ays_quiz_container.data('questEffect'), currentStep, ays_quiz_container.find('.step.ays_thank_you_fs'));
4007                                        var ays_finish_button = container.find('input.ays_finish');
4008                                        if(ays_finish_button.prop('disabled')){
4009                                            ays_finish_button.prop('disabled', false);
4010                                        }
4011                                        ays_finish_button.addClass('ays-quiz-after-timer-end');
4012                                        ays_finish_button.trigger('click');
4013                                    }
4014                                }else{
4015                                    if(container.find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){
4016                                        container.find('.ays-quiz-timer').parent().slideUp(500);
4017                                    }
4018                                    container.find('.ays-live-bar-wrap').removeClass('rubberBand').addClass('bounceOut');
4019                                    container.find('.ays-live-bar-percent').removeClass('rubberBand').addClass('bounceOut');
4020                                    setTimeout(function () {
4021                                        container.find('.ays-live-bar-wrap').css('display','none');
4022                                        container.find('.ays-live-bar-percent').css('display','none');
4023                                    },300);
4024                                    aysAnimateStep(ays_quiz_container.data('questEffect'), currentStep, infoFormLast.parent());
4025                                    container.find('div.step').each(function (index) {
4026                                        $(this).css('display', 'none');
4027                                        $(this).removeClass('active-step')
4028                                    });
4029                                    infoFormLast.parent().css('display', 'flex');
4030                                    infoFormLast.parent().addClass('active-step');
4031                                    var ays_finish_button = container.find('input.ays_finish');
4032                                    ays_finish_button.addClass('ays-quiz-after-timer-end');
4033                                }
4034                                container.parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').slide
4034Up(500);
4035                            }
4036                        }, 1000);
4037                    }
4038                } else {
4039                    alert('Wanna cheat??');
4040                    if (window.location != window.parent.location) {
4041                        parent.location.reload();
4042                    } else {
4043                        window.location.reload();
4044                    }
4045                }
4046            }
4047        }
4048
4049        function questionTimerInit( container ){
4050            var questions = container.find('div[data-question-id]:not([data-type="custom"])');
4051            window.aysQuizQuestionTimers[quizId] = {};
4052            for( var i=0; i < questions.length; i++ ) {
4053                var questionID = questions[i].dataset.questionId;
4054                window.aysQuizQuestionTimers[quizId][questionID] = {
4055                    active: false,
4056                    timeout: null,
4057                    timer: null,
4058                    ended: false,
4059                    stopped: false,
4060                    switchTimeout: null
4061                };
4062            }
4063        }
4064
4065        function checkQuestionTimer( container ){
4066            if( window.aysQuizQuestionTimers[quizId] ) {
4067                var questions = container.find('div[data-question-id]');
4068                var remainingQuestionsEmpty = [];
4069                for (var i = 0; i < questions.length; i++) {
4070                    var questionID = questions[i].dataset.questionId;
4071
4072                    if(
4073                        window.aysQuizQuestionTimers[quizId][questionID]
4074                        &&
4075                        (
4076                            window.aysQuizQuestionTimers[quizId][questionID].ended === true
4077                            ||
4078                            window.aysQuizQuestionTimers[quizId][questionID].stopped === true
4079                        )
4080                    ) {
4081                        continue;
4082                    } else {
4083                        if ( ays_quiz_is_question_empty( $(questions[i]) ) === false ) {
4084                            remainingQuestionsEmpty.push({
4085                                item: $(questions[i]),
4086                                id: questionID
4087                            });
4088                        }
4089                    }
4090                }
4091
4092                if( remainingQuestionsEmpty.length > 0 ){
4093                    return remainingQuestionsEmpty[0].id;
4094                }else{
4095                    return false;
4096                }
4097            }
4098            return false;
4099        }
4100
4101        function stopQuestionTimer( container, questionID, quizId ){
4102            if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
4103                if (myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'question_timer') {
4104                    if (window.aysQuizQuestionTimers && window.aysQuizQuestionTimers[quizId]) {
4105                        if ( window.aysQuizQuestionTimers[quizId][questionID] ) {
4106                            // clearInterval(window.aysQuizQuestionTimers[quizId][questionID].timeout);
4107                            window.aysQuizQuestionTimers[quizId][questionID].stopped = true;
4108                            var qid = checkQuestionTimer( container, quizId );
4109                            if (qid === false) {
4110                                container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4111                            }
4112                        }
4113                    }
4114                }
4115            }
4116        }
4117
4118        function questionTimer( questionContainer, questionID ){
4119            var container = questionContainer.parents('.ays-quiz-container');
4120            if( ! questionID ){
4121                return;
4122            }
4123
4124            if( myOptions.enable_timer && myOptions.enable_timer !== 'on' ){
4125                return;
4126            }
4127
4128            if (myOptions.quiz_timer_type && myOptions.quiz_timer_type !== 'question_timer') {
4129                return;
4130            }
4131
4132            if ( ! window.aysQuizQuestionTimers || ! window.aysQuizQuestionTimers[quizId] ) {
4133                return;
4134            }
4135
4136            if ( questionContainer.data('type') === 'custom' ) {
4137                for (var i in window.aysQuizQuestionTimers[quizId]) {
4138                    clearInterval(window.aysQuizQuestionTimers[quizId][i].timeout);
4139                    clearInterval(window.aysQuizQuestionTimers[quizId][i].switchTimeout);
4140                    window.aysQuizQuestionTimers[quizId][i].active = false;
4141                }
4142
4143                container.find('div.ays-quiz-after-timer').slideDown(500);
4144                container.find('div.ays-quiz-timer').slideUp(500);
4145                container.find('.ays_quiz_timer_container').removeClass("ays-quiz-timer-end-for-required");
4146                questionContainer.find('.ays-quiz-answers').css({
4147                    'pointer-events': 'none'
4148                });
4149                container.find('.ays_quiz_timer_container').slideUp(500);
4150
4151                var qid = checkQuestionTimer( container );
4152                if (qid === false) {
4153                    container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4154                }
4155            }
4156
4157            if ( ! window.aysQuizQuestionTimers[quizId][questionID] ) {
4158                return;
4159            }
4160
4161            for ( var i in window.aysQuizQuestionTimers[quizId] ){
4162                if( window.aysQuizQuestionTimers[quizId][i].active ){
4163                    clearInterval( window.aysQuizQuestionTimers[quizId][i].timeout );
4164                    clearInterval( window.aysQuizQuestionTimers[quizId][i].switchTimeout );
4165                    window.aysQuizQuestionTimers[quizId][i].active = false;
4166                }
4167            }
4168
4169            container.find('div.ays-quiz-timer').html("--:--");
4170            var timeForShow = "";
4171
4172            var isRequiredQuestion = myOptions.make_questions_required && myOptions.make_questions_required === "on";
4173            var enablePrevButton = myOptions.enable_previous_button && myOptions.enable_previous_button === 'on';
4174            var enableNextButton = myOptions.enable_next_button && myOptions.enable_next_button === 'on';
4175            var enableClearAnswer = myOptions.enable_clear_answer && myOptions.enable_clear_answer === 'on';
4176            var enableArrows = myOptions.enable_arrows && myOptions.enable_arrows === 'on';
4177
4178            clearInterval(explanationTimeout);
4179
4180            var qid = checkQuestionTimer( container );
4181            if (qid === false) {
4182                container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4183                container.find('input.ays_finish').addClass('ays_timer_end');
4184            }
4185
4186            if ( window.aysQuizQuestionTimers[quizId][questionID].ended === true ) {
4187                if (enableNextButton) {
4188                    if (enableArrows) {
4189                        questionContainer.find('i.ays_next_arrow').removeAttr('disabled');
4190                    } else {
4191                        questionContainer.find('input.ays_next').removeAttr('disabled');
4192                    }
4193                }
4194
4195                if( isRequiredQuestion ){
4196                    if (enableArrows) {
4197                        if (!questionContainer.find('i.ays_next_arrow').hasClass('ays_display_none')){
4198                            questionContainer.find('i.ays_next_arrow').removeAttr('disabled');
4199                        }
4200                    } else {
4201                        if (!questionContainer.find('input.ays_next').hasClass('ays_display_none')){
4202                            questionContainer.find('input.ays_next').removeAttr('disabled');
4203                        }
4204                    }
4205                }
4206
4207                if( enableClearAnswer ){
4208                    if (enableArrows) {
4209                        questionContainer.find('i.ays_clear_answer').attr('disabled', 'disabled');
4210                    } else {
4211                        questionContainer.find('input.ays_clear_answer').attr('disabled', 'disabled');
4212                    }
4213                }
4214            }
4215
4216            if ( myOptions.timer !== undefined ) {
4217                var timer = Number( myOptions.timer );
4218                if(
4219                    window.aysQuizQuestionTimers[quizId][questionID].timeout !== null
4220                    &&
4221                    window.aysQuizQuestionTimers[quizId][questionID].timer !== null
4222                ) {
4223                    timer = window.aysQuizQuestionTimers[quizId][questionID].timer;
4224                }
4225
4226                if( window.aysQuizQuestionTimers[quizId][questionID].ended === false ) {
4227                    if ( timer <= 0 ){
4228                        window.aysQuizQuestionTimers[quizId][questionID].ended = true;
4229                        if (enableNextButton) {
4230                            if (enableArrows) {
4231                                questionContainer.find('i.ays_next_arrow').removeAttr('disabled');
4232                            } else {
4233                                questionContainer.find('input.ays_next').removeAttr('disabled');
4234                            }
4235                        }
4236                    }
4237                }
4238
4239                if (
4240                    window.aysQuizQuestionTimers[quizId][questionID].ended === true
4241                    &&
4242                    window.aysQuizQuestionTimers[quizId][questionID].stopped === false
4243                ) {
4244                    questionContainer.find('.ays-quiz-answers').css({
4245                        'pointer-events': 'none'
4246                    });
4247                    questionContainer.find('[name^="ays_questions"]').attr('disabled', 'disabled');
4248                    questionContainer.find('select.ays-select').select2('close');
4249                    container.find('.ays_quiz_timer_container').removeClass("ays-quiz-timer-end-for-required");
4250                    container.find('div.ays-quiz-timer').slideUp();
4251
4252                    if ( ! container.find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text') ) {
4253                        container.find('.ays_quiz_timer_container').css({
4254                            'position': 'static',
4255                            'height': '100%',
4256                        });
4257
4258                        container.find('.ays_quiz_timer_container').slideDown(500);
4259                        container.find('div.ays-quiz-after-timer').slideDown(500);
4260                    } else {
4261                        container.find('.ays_quiz_timer_container').slideUp(500);
4262                        container.find('div.ays-quiz-after-timer').slideUp(500);
4263                    }
4264                } else if (
4265                    window.aysQuizQuestionTimers[quizId][questionID].ended === true
4266                    &&
4267                    window.aysQuizQuestionTimers[quizId][questionID].stopped === true
4268                ) {
4269                    container.find('.ays_quiz_timer_container').slideUp();
4270                } else {
4271                    container.find('div.ays-quiz-after-timer').slideUp();
4272                    container.find('div[data-question-id="'+ questionID +'"]').find('.ays-quiz-answers').removeAttr('style');
4273                }
4274
4275                if ( !isNaN(timer) && timer !== 0 ) {
4276                    timer += 2;
4277                    var countDownDate = new Date().getTime() + (timer * 1000);
4278
4279                    // Message before timer
4280                    var quiz_message_before_timer = (myOptions.quiz_message_before_timer && myOptions.quiz_message_before_timer !== "") ? (myOptions.quiz_message_before_timer) : '';
4281                    if (quiz_message_before_timer !== '') {
4282                        quiz_message_before_timer = quiz_message_before_timer.replace(/(["'])/g, "\\$1") + " ";
4283                        $(document).find('html > head').append('<style> #ays-quiz-container-' + quizId + ' div.ays-quiz-timer.ays-quiz-message-before-timer:before{content: "' + quiz_message_before_timer + '"; }</style>');
4284                    }
4285
4286                    if ( ! window.aysQuizQuestionTimers[quizId][questionID].ended ) {
4287                        window.aysQuizQuestionTimers[quizId][questionID].active = true;
4288                        window.aysQuizQuestionTimers[quizId][questionID].timeout = setInterval(function () {
4289
4290                            var now = new Date().getTime();
4291                            var distance = countDownDate - Math.
4291ceil(now / 1000) * 1000;
4292                            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
4293                            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
4294                            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
4295                            window.aysQuizQuestionTimers[quizId][questionID].timer = Math.floor(distance / 1000);
4296
4297                            if (hours <= 0) {
4298                                hours = null;
4299                            } else if (hours < 10) {
4300                                hours = '0' + hours;
4301                            }
4302                            if (minutes < 10) {
4303                                minutes = '0' + minutes;
4304                            }
4305                            if (seconds < 10) {
4306                                seconds = '0' + seconds;
4307                            }
4308
4309                            timeForShow = ((hours == null) ? "" : (hours + ":")) + minutes + ":" + seconds;
4310                            if (distance <= 1000) {
4311                                timeForShow = ((hours == null) ? "" : "00:") + "00:00";
4312                            }
4313
4314                            if( window.aysQuizQuestionTimers[quizId][questionID].stopped === true ){
4315                                if (distance <= 1) {
4316                                    container.find('div.ays-quiz-after-timer').slideDown(500);
4317                                    container.find('div.ays-quiz-timer').slideUp(500);
4318                                    container.find('.ays_quiz_timer_container').removeClass("ays-quiz-timer-end-for-required");
4319                                    questionContainer.find('.ays-quiz-answers').css({
4320                                        'pointer-events': 'none'
4321                                    });
4322
4323                                    if( enableClearAnswer ){
4324                                        if (enableArrows) {
4325                                            questionContainer.find('i.ays_clear_answer').attr('disabled', 'disabled');
4326                                        } else {
4327                                            questionContainer.find('input.ays_clear_answer').attr('disabled', 'disabled');
4328                                        }
4329                                    }
4330
4331
4332                                    clearInterval(window.aysQuizQuestionTimers[quizId][questionID].timeout);
4333                                    window.aysQuizQuestionTimers[quizId][questionID].active = false;
4334                                    window.aysQuizQuestionTimers[quizId][questionID].ended = true;
4335                                    window.aysQuizQuestionTimers[quizId][questionID].timer = -1;
4336                                    container.find('.ays_quiz_timer_container').slideUp(500);
4337
4338                                    var qid = checkQuestionTimer( container );
4339                                    if (qid === false) {
4340                                        container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4341                                    }
4342                                    return;
4343                                }
4344                            }
4345
4346                            container.find('div.ays-quiz-timer').html(timeForShow);
4347                            container.find('.ays_quiz_timer_container').show(500);
4348
4349                            container.find('div.ays-quiz-timer').show(500);
4350
4351                            if (container.find('.ays-quiz-timer').length === 0) {
4352                                clearInterval(window.aysQuizQuestionTimers[quizId][questionID].timeout);
4353                                window.aysQuizQuestionTimers[quizId][questionID].active = false;
4354                                container.find('.ays_quiz_timer_container').slideUp(500);
4355                            }
4356
4357                            if (distance <= 1) {
4358                                clearInterval(window.aysQuizQuestionTimers[quizId][questionID].timeout);
4359                                window.aysQuizQuestionTimers[quizId][questionID].active = false;
4360                                window.aysQuizQuestionTimers[quizId][questionID].ended = true;
4361
4362                                questionContainer.find('.ays-quiz-answers').css({
4363                                    'pointer-events': 'none'
4364                                })
4365
4366                                if (!container.find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')) {
4367                                    container.find('.ays_quiz_timer_container').css({
4368                                        'position': 'static',
4369                                        'height': '100%',
4370                                    });
4371
4372                                    container.find('.ays_quiz_timer_container').show();
4373                                    container.find('div.ays-quiz-timer').slideUp();
4374                                    container.find('div.ays-quiz-after-timer').addClass("ays-quiz-timer-end");
4375                                    container.find('.ays_quiz_timer_container').addClass("ays-quiz-timer-end-for-required");
4376                                    container.find('div.ays-quiz-after-timer').slideDown(500);
4377                                } else {
4378                                    container.find('.ays_quiz_timer_container').slideUp(500);
4379                                    container.find('.ays_quiz_timer_container').addClass("ays-quiz-timer-end-for-required");
4380                                }
4381
4382                                questionContainer.find('[name^="ays_questions"]').attr('disabled', 'disabled');
4383                                questionContainer.find('[name^="ays_questions"]').trigger('blur');
4384                                questionContainer.find('select.ays-select').trigger('blur');
4385                                questionContainer.find('select.ays-select').select2('close');
4386
4387                                if( isRequiredQuestion === true ){
4388                                    if( aysThisQuizBullets !== null ) {
4389                                        var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + questionID + '"]');
4390                                        thisBullet.removeClass('ays-has-error');
4391                                    }
4392                                    questionContainer.removeClass('ays-has-error');
4393
4394                                    if( enableNextButton ){
4395                                        if( enableArrows ){
4396                                            questionContainer.find('i.ays_next_arrow').removeAttr('disabled');
4397                                        }else{
4398                                            questionContainer.find('input.ays_next').removeAttr('disabled');
4399                                        }
4400
4401                                        if( myOptions.enable_navigation_bar && myOptions.enable_navigation_bar === 'on' ) {
4402                                            if ( questionContainer.find('input.ays_next').hasClass('ays_finish') ) {
4403                                                aysThisQuizQuestionsFirstPass = false;
4404                                            }
4405
4406                                            if( aysThisQuizQuestionsFirstPass === false ) {
4407                                                var qid = checkQuestionTimer(container);
4408                                                if (qid === false) {
4409                                                    container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4410                                                }
4411                                            }
4412                                        }
4413
4414                                    } else {
4415                                        var isNeedToSwitch = true;
4416                                        if( enableArrows ){
4417                                            if (!questionContainer.find('i.ays_next_arrow').hasClass('ays_display_none')){
4418                                                isNeedToSwitch = false;
4419                                            }
4420                                        }else{
4421                                            if (!questionContainer.find('input.ays_next').hasClass('ays_display_none')){
4422                                                isNeedToSwitch = false;
4423                                            }
4424                                        }
4425
4426                                        if( myOptions.enable_navigation_bar && myOptions.enable_navigation_bar === 'on' ) {
4427                                            if ( questionContainer.find('input.ays_next').hasClass('ays_finish') ) {
4428                                                aysThisQuizQuestionsFirstPass = false;
4429                                            }
4430
4431                                            if( aysThisQuizQuestionsFirstPass === false ) {
4432                                                isNeedToSwitch = false;
4433
4434                                                var qid = checkQuestionTimer(container);
4435                                                if (qid !== false) {
4436                                                    container.find('.ays_questions_nav_question[data-id="' + qid + '"]').trigger('click');
4437                                                } else {
4438                                                    container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4439                                                    questionContainer.css('display', 'none');
4440                                                    container.find('.ays_quiz_timer_container').slideUp(500);
4441                                                    container.find('input.ays_finish').trigger('click');
4442                                                }
4443                                            }
4444                                        }
4445                                        if( isNeedToSwitch ) {
4446                                            window.aysQuizQuestionTimers[quizId][questionID].switchTimeout = setTimeout(function () {
4447                                                questionContainer.find('input.ays_next').trigger('click');
4448                                            }, 1500 );
4449                                        }
4450                                    }
4451
4452                                    if (enableArrows) {
4453                                        if (!questionContainer.find('i.ays_next_arrow').hasClass('ays_display_none')){
4454                                            questionContainer.find('i.ays_next_arrow').removeAttr('disabled');
4455                                        }
4456                                    } else {
4457                                        if (!questionContainer.find('input.ays_next').hasClass('ays_display_none')){
4458                                            questionContainer.find('input.ays_next').removeAttr('disabled');
4459                                        }
4460                                    }
4461
4462                                    if( enableClearAnswer ){
4463                                        if (enableArrows) {
4464                                            questionContainer.find('i.ays_clear_answer').attr('disabled', 'disabled');
4465                                        } else {
4466                                            questionContainer.find('input.ays_clear_answer').attr('disabled', 'disabled');
4467                                        }
4468                                    }
4469                                }else{
4470                                    if( enableNextButton ){
4471                                        if( enableArrows ){
4472                                            questionContainer.find('i.ays_next_arrow').removeAttr('disabled');
4473                                        }else{
4474                                            questionContainer.find('input.ays_next').removeAttr('disabled' );
4475                                        }
4476
4477                                        if( myOptions.enable_navigation_bar && myOptions.enable_navigation_bar === 'on' ) {
4478                                            if ( questionContainer.find('input.ays_next').hasClass('ays_finish') ) {
4479                                                aysThisQuizQuestionsFirstPass = false;
4480                                            }
4481
4482                                            if( aysThisQuizQuestionsFirstPass === false ) {
4483                                                var qid = checkQuestionTimer(container);
4484                                                if (qid === false) {
4485                                                    container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4486                                                }
4487                                            }
4488                                        }
4489
4490                                    } else {
4491                                        var isNeedToSwitch = true;
4492                                        if (enableArrows) {
4493                                            if (!questionContainer.find('i.ays_next_arrow').hasClass('ays_display_none')) {
4494                                                isNeedToSwitch = false;
4495                                            }
4496                                        } else {
4497                                            if (!questionContainer.find('input.ays_next').hasClass('ays_display_none')) {
4498                                                isNeedToSwitch = false;
4499                                            }
4500                                        }
4501
4502                                        if (myOptions.enable_navigation_bar && myOptions.enable_navigation_bar === 'on') {
4503                                            if (questionContainer.find('input.ays_next').hasClass('ays_finish')) {
4504                                                aysThisQuizQuestionsFirstPass = false;
4505                                            }
4506
4507                                            if (aysThisQuizQuestionsFirstPass === false) {
4508                                                isNeedToSwitch = false;
4509
4510                                                var qid = checkQuestionTimer(container);
4511                                                if (qid !== false) {
4512                                                    container.find('.ays_questions_nav_question[data-id="' + qid + '"]').trigger('click');
4513                                                } else {
4514                                                    container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4515                                                    questionContainer.css('display', 'none');
4516                                                    container.find('.ays_quiz_timer_container').slideUp(500);
4517                                                    container.find('input.ays_finish').trigger('click');
4518                                                }
4519                                            }
4520                                        }
4521
4522                                        if (isNeedToSwitch) {
4523                                            window.aysQuizQuestionTimers[quizId][questionID].switchTimeout = setTimeout(function () {
4524                                                questionContainer.find('input.ays_next').trigger('click');
4525                                            }, 1500);
4526                                        }
4527                                    }
4528
4529                                    if( myOptions.enable_navigation_bar && myOptions.enable_navigation_bar === 'on' ) {
4530                                        if ( questionContainer.find('input.ays_next').hasClass('ays_finish') ) {
4531                                            aysThisQuizQuestionsFirstPass = false;
4532                                        }
4533
4534                                        if( aysThisQuizQuestionsFirstPass === false ) {
4535                                            var qid = 
4535checkQuestionTimer(container);
4536                                            if (qid === false) {
4537                                                container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
4538                                            }
4539                                        }
4540                                    }
4541
4542                                    if( enableClearAnswer ){
4543                                        if (enableArrows) {
4544                                            questionContainer.find('i.ays_clear_answer').attr('disabled', 'disabled');
4545                                        } else {
4546                                            questionContainer.find('input.ays_clear_answer').attr('disabled', 'disabled');
4547                                        }
4548                                    }
4549                                }
4550                            }
4551                        }, 1000);
4552                    }
4553                }
4554            }
4555        }
4556
4557        function checkFillInTheBlankQuestion( fillInBlankAnswers, questionId, _this, correct_img_URL_HTML, wrong_img_URL_HTML ){
4558            var trueAnswered = false;
4559
4560            var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
4561
4562            var question_original_html = _this.parents('.step').find('.ays_quiz_question');
4563            var question_original_html_clone = question_original_html.clone(true, true);
4564
4565            question_original_html_clone.find('.ays_buttons_div').remove();
4566
4567            if( fillInBlankAnswers.length > 0 ){
4568
4569                for(var i=0; i < fillInBlankAnswers.length; i++){
4570                    var userAnsweredText = fillInBlankAnswers.eq(i).val().trim();
4571                    var answerID = fillInBlankAnswers.eq(i).attr('data-answer-id');
4572                    var questionId = fillInBlankAnswers.eq(i).parents('.step').data('questionId');
4573
4574                    var trueAnswered = false;
4575
4576                    // Enable case sensitive text
4577                    var enable_case_sensitive_text = (myQuizOptions[questionId].enable_case_sensitive_text && myQuizOptions[questionId].enable_case_sensitive_text != "") ? myQuizOptions[questionId].enable_case_sensitive_text : false;
4578
4579                    var thisQuestionCorrectAnswer_Arr = myQuizOptions[questionId].question_answer.length > 0 ? "" : myQuizOptions[questionId].question_answer;
4580
4581                    var thisQuestionCorrectAnswer = thisQuestionCorrectAnswer_Arr[answerID];
4582                    var thisQuestionAnswer = thisQuestionCorrectAnswer.toLowerCase();
4583
4584                    if ( enable_case_sensitive_text ) {
4585                        thisQuestionAnswer = thisQuestionCorrectAnswer;
4586                    }
4587
4588                    thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes().split('%%%');
4589                    for(var i_answer = 0; i_answer < thisQuestionAnswer.length; i_answer++){
4590                        if ( enable_case_sensitive_text ) {
4591                            if(userAnsweredText == thisQuestionAnswer[i_answer].trim()){
4592                                trueAnswered = true;
4593                                break;
4594                            }
4595                        } else {
4596                            if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i_answer].trim()){
4597                                trueAnswered = true;
4598                                break;
4599                            }
4600                        }
4601                    }
4602
4603                    if(trueAnswered){
4604                        fillInBlankAnswers.eq(i).next().val(1);
4605                    }else{
4606                        fillInBlankAnswers.eq(i).next().val(0);
4607                        if(thisQuestionCorrectAnswer == ''){
4608                            fillInBlankAnswers.eq(i).attr('chishtpatasxan', '-');
4609                        }else{
4610                            fillInBlankAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer);
4611                        }
4612                    }
4613
4614                    fillInBlankAnswers.eq(i).removeAttr('disabled');
4615
4616                }
4617
4618                var if_fill_in_blank_empty = false;
4619                var fill_in_blank_empty_arr = new Array();
4620                var is_user_answer_correct = true;
4621                var fillInBlankAnswers_last = false;
4622                for (var i = 0; i < fillInBlankAnswers.length; i++) {
4623                    var fill_in_blank_answer = $( fillInBlankAnswers[i] );
4624                    // fill_in_blank_answer.next().remove();
4625                    // fill_in_blank_answer.next().next().remove();
4626                    fill_in_blank_answer.attr('disabled', 'disabled');
4627                    var fillInBlankAnswers_last = false;
4628                    if( (fillInBlankAnswers.length - 1) == i ){
4629                        var fillInBlankAnswers_last = true;
4630                    }
4631
4632                    if( fill_in_blank_answer.val() == '' ){
4633                        fill_in_blank_empty_arr.push('empty');
4634                    }
4635
4636                    if( fill_in_blank_empty_arr.length == fillInBlankAnswers.length ){
4637                        if_fill_in_blank_empty = true;
4638                    }
4639
4640                    if(if_fill_in_blank_empty && fillInBlankAnswers_last){
4641                        if(showOnlyWrongAnswer === false){
4642                            // var rightAnswerText = '<div class="ays-text-right-answer">';
4643                            // var thisQuestionAnswer = fill_in_blank_answer.attr('chishtpatasxan');
4644                            // if(typeof thisQuestionAnswer != 'undefined'){
4645                            //     thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
4646                            //     thisQuestionAnswer = thisQuestionAnswer.split('%%%');
4647                            // }else{
4648                            //     thisQuestionAnswer = [''];
4649                            // }
4650                            // rightAnswerText += thisQuestionAnswer[0].trim();
4651
4652                            // rightAnswerText += '</div>';
4653                            // if(fill_in_blank_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
4654                            //     fill_in_blank_answer.parents('.ays-quiz-answers').append(rightAnswerText);
4655                            // }
4656                            // fill_in_blank_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
4657                            //     'display': 'block'
4658                            // });
4659                        }
4660                        // fill_in_blank_answer.css('background-color', 'rgba(243,134,129,0.4)');
4661                        // fill_in_blank_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
4662
4663                        // if (wrong_img_URL_HTML != "") {
4664                        //     var if_img_exists = fill_in_blank_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
4665                        //     if ( if_img_exists.length <= 0 ) {
4666                        //         fill_in_blank_answer.parent().append(wrong_img_URL_HTML);
4667                        //     }
4668                        // }
4669
4670                        // var _fill_in_blank_answer_parent = fill_in_blank_answer.parents('.ays-abs-fs');
4671
4672                        // _fill_in_blank_answer_parent.html(fieldset_html);
4673                        // _fill_in_blank_answer_parent.find('.ays_fieldset').append(ays_quiz_question_html);
4674                        // // _fill_in_blank_answer_parent.find('.ays_fieldset').append(fill_in_blank_answer);
4675                        // _fill_in_blank_answer_parent.find('.ays_fieldset').append(ays_quiz_question_img_html);
4676                        // // _fill_in_blank_answer_parent.find('.ays_fieldset').append(fill_in_blank_answer.parents('.ays-quiz-answers'));
4677                        
4678                        // for (var j = 0; j < question_parts_arr.length; j++) {
4679                        //     _fill_in_blank_answer_parent.find('.ays_fieldset').append( question_parts_arr[j] );
4680                        // }
4681
4682                        // _fill_in_blank_answer_parent.parents('.ays-abs-fs').css({
4683                        //     'padding': '7px'
4684                        // });
4685                    }else{
4686                        if(parseInt(fill_in_blank_answer.next().val()) == 1){
4687                            fill_in_blank_answer.css('background-color', 'rgba(39,174,96,0.5)');
4688                            fill_in_blank_answer.css('width', 'auto');
4689
4690                        }else{
4691                            fill_in_blank_answer.css('background-color', 'rgba(243,134,129,0.4)');
4692                            fill_in_blank_answer.css('width', 'auto');
4693
4694                            if( is_user_answer_correct ){
4695                                is_user_answer_correct = false;
4696                            }
4697
4698                            if(showOnlyWrongAnswer === false){
4699                                // var rightAnswerText = '<div class="ays-text-right-answer">';
4700                                // var thisQuestionAnswer = fill_in_blank_answer.attr('chishtpatasxan');
4701                                // if(typeof thisQuestionAnswer != 'undefined'){
4702                                //     thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
4703                                //     thisQuestionAnswer = thisQuestionAnswer.split('%%%');
4704                                // }else{
4705                                //     thisQuestionAnswer = [''];
4706                                // }
4707                                // rightAnswerText += thisQuestionAnswer[0].trim();
4708
4709                                // rightAnswerText += '</div>';
4710                                // if(fill_in_blank_answer.parents('.ays_quiz_question').find('.ays-text-right-answer').length == 0){
4711                                //     fill_in_blank_answer.parents('.ays_quiz_question').append(rightAnswerText);
4712                                // }
4713                                // fill_in_blank_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
4714                                //     'display': 'block'
4715                                // });
4716                                fill_in_blank_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
4717                            }
4718                        }
4719
4720                        
4721                    }
4722                }
4723
4724                if( fillInBlankAnswers_last ){
4725                    if( is_user_answer_correct === true ){
4726                        // answerIsRight = true;
4727                        trueAnswered = true;
4728                        if (correct_img_URL_HTML != "") {
4729                            var if_img_exists = $( fillInBlankAnswers[0] ).parents('.ays_quiz_question').find(".ays-quiz-check-button-right-wrong-icon");
4730                            if ( if_img_exists.length <= 0 ) {
4731                                $( fillInBlankAnswers[0] ).parent().append(correct_img_URL_HTML);
4732                            }
4733                        }
4734                    } else {
4735                        if (wrong_img_URL_HTML != "") {
4736                            var if_img_exists = $( fillInBlankAnswers[0] ).parents('.ays_quiz_question').find(".ays-quiz-check-button-right-wrong-icon");
4737                            if ( if_img_exists.length <= 0 ) {
4738                                $( fillInBlankAnswers[0] ).parent().append(wrong_img_URL_HTML);
4739                            }
4740                        }
4741
4742                        var thisAnswerOptions = myQuizOptions[questionId];
4743                        var thisQuestionAnswer = (typeof myQuizOptions[questionId].question_answer != 'undefined') ? myQuizOptions[questionId].question_answer : new Array();
4744
4745                        var rightAnswerTextStart = "";
4746                        var rightAnswerTextEnd = "";
4747                        rightAnswerTextStart += '<div class="ays-quiz-answers" style="pointer-events: none;">';
4748                            rightAnswerTextStart += '<div class="ays-text-right-answer" style="display: block;">';
4749
4750                            rightAnswerTextEnd += '<div';
4751                        rightAnswerTextEnd += '<div';
4752
4753                        if(typeof thisQuestionAnswer != 'undefined'){
4754                            var only_question_original_html_clone = $( rightAnswerTextStart + question_original_html_clone.html() + rightAnswerTextEnd);
4755
4756                            for( var answerId in thisQuestionAnswer ) {
4757
4758                                var rightAnswerText = aysEscapeHtmlDecode( thisQuestionAnswer[answerId] ).aysStripSlashes();
4759                                rightAnswerText = rightAnswerText.split('%%%');
4760                                rightAnswerText = rightAnswerText[0].trim();
4761
4762                                var rightAnswerHTML = $('<strong class="ays-quiz-fill-in-blank-input-right-wrong-answer">'+ rightAnswerText +'</strong>');
4763
4764                                var fill_in_blank_answer_input = only_question_original_html_clone.find('.ays-quiz-fill-in-blank-input[data-answer-id="'+ answerId +'"]');
4765
4766                                fill_in_blank_answer_input.replaceWith( rightAnswerHTML );
4767                            }
4768
4769                            fill_in_blank_answer.parents('.ays_quiz_question').append(only_question_original_html_clone);
4770                            fill_in_blank_answer.parents('.ays_quiz_question').find('script').remove();
4771
4772                        }
4773                    }
4774                }
4775            }
4776
4777            return trueAnswered;
4778        }
4779
4780        function checkCheckboxRadioQuestion(e, _this) {
4781
4782            var quizContainer = _this.parents('.ays-quiz-container');
4783            var quizId = _this.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
4784
4785            var parentStep = _this.parents('.step');
4786            var questionID = parentStep.data('questionId');
4787            var questionType = parentStep.attr('data-type');
4788            var answerId = _this.val();
4789
4790            var quizForm = quizContainer.find('form.ays-quiz-form');
4791
4792            var checkboxQuestionTypeFlag = true;
4793            if( questionType == 'checkbox' && quizForm.hasClass('enable_correction') ){
4794                if( !_this.hasClass('ays-quiz-check-button-clicked') ){
4795                    checkboxQuestionTypeFlag = false;
4796                }
4797            }
4798
4799            if( typeof questionID != "undefined" && questionID !== null && quizForm.hasClass('enable_correction') ){
4800
4801                var thisQuestionCorrectAnswer = myQuizOptions[questionID].question_answer.length <= 0 ? array() : myQuizOptions[questionID].question_answer;
4802                var ifCorrectAnswer = thisQuestionCorrectAnswer[answerId] == '' ? '' : thisQuestionCorrectAnswer[answerId];
4803                if( typeof ifCorrectAnswer != "undefined" ){
4804                    _this.parents('.ays-field').find('input[name="ays_answer_
4804correct[]"]').val(ifCorrectAnswer);
4805
4806                    if( ifCorrectAnswer == '0' && questionType === 'checkbox' && quizForm.hasClass('enable_correction') ){
4807                        if( _this.hasClass('ays-quiz-check-button-clicked') ){
4808                            
4809                            if( _this.parents('.ays-field').find('input:checked').length == 0 ){
4810                                _this.parents('.ays-field').css({
4811                                    'pointer-events': 'none'
4812                                });
4813                                return false;
4814                            }
4815                        }
4816                    }
4817
4818                    if( ifCorrectAnswer == '0' && questionType === 'radio' && _this.parents('form.ays-quiz-form').hasClass('enable_correction') ){
4819
4820                        for (var question_answer_ID in thisQuestionCorrectAnswer) {
4821                            var UserAnswered_true_or_false = thisQuestionCorrectAnswer[question_answer_ID];
4822                            parentStep.find('.ays-quiz-answers .ays-field input[value="'+ question_answer_ID +'"]').prev().val(UserAnswered_true_or_false);
4823                        }
4824                    }
4825                }
4826            }
4827
4828            if(typeof myOptions != 'undefined'){
4829                var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
4830                var isRequiredQuestion2 = true;
4831                if(isRequiredQuestion2 === true){
4832                    if(_this.attr('type') === 'radio' || _this.attr('type') === 'checkbox'){
4833                        if(_this.parents('div[data-question-id]').find('input[name^="ays_questions"]:checked').length != 0){
4834                            if ( _this.attr('type') === 'checkbox' ) {
4835                                var checkedMinSelCount = aysCheckMinimumCountCheckbox( _this.parents('div[data-question-id]'), myQuizOptions );
4836
4837                                if( checkedMinSelCount == true ){
4838                                    if (!_this.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
4839                                        _this.parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
4840                                        _this.parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
4841
4842                                    }else if(!_this.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
4843                                        _this.parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
4844                                        _this.parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
4845                                    }
4846                                }else{
4847                                    if (!_this.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
4848
4849                                        _this.parents('div[data-question-id]').find('input.ays_next').attr('disabled', 'disabled');
4850                                        _this.parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', 'disabled');
4851
4852                                    }else if(!_this.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
4853                                        _this.parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', 'disabled');
4854                                        _this.parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', 'disabled');
4855                                    }
4856                                }
4857                            } else {
4858                                if (!_this.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
4859                                    _this.parents('div[data-question-id]').find('input.ays_next').removeAttr('disabled');
4860                                    _this.parents('div[data-question-id]').find('input.ays_early_finish').removeAttr('disabled');
4861
4862                                }else if(!_this.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
4863                                    _this.parents('div[data-question-id]').find('i.ays_next_arrow').removeAttr('disabled');
4864                                    _this.parents('div[data-question-id]').find('i.ays_early_finish').removeAttr('disabled');
4865                                }
4866                            }
4867                        }else{
4868                            if( isRequiredQuestion ){
4869                                if (!_this.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none')){
4870
4871                                    _this.parents('div[data-question-id]').find('input.ays_next').attr('disabled', 'disabled');
4872                                    _this.parents('div[data-question-id]').find('input.ays_early_finish').attr('disabled', 'disabled');
4873
4874                                }else if(!_this.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
4875                                    _this.parents('div[data-question-id]').find('i.ays_next_arrow').attr('disabled', 'disabled');
4876                                    _this.parents('div[data-question-id]').find('i.ays_early_finish').attr('disabled', 'disabled');
4877                                }
4878                            }
4879                        }
4880                    }
4881                }
4882            }
4883
4884            var isRequiredQuestion = myOptions.make_questions_required && myOptions.make_questions_required === "on";
4885
4886            if(_this.parents('.step').hasClass('not_influence_to_score')){
4887                if(_this.attr('type') === 'radio') {
4888                    _this.parents('.ays-quiz-answers').find('.checked_answer_div').removeClass('checked_answer_div');
4889                    _this.parents('.ays-field').addClass('checked_answer_div');
4890                }
4891                if(_this.attr('type') === 'checkbox') {
4892                    if(!_this.parents('.ays-field').hasClass('checked_answer_div')){
4893                        _this.parents('.ays-field').addClass('checked_answer_div');
4894                    }else{
4895                        _this.parents('.ays-field').removeClass('checked_answer_div');
4896                    }
4897                } 
4898                var checked_inputs = _this.parents().eq(1).find('input:checked');
4899                if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') && checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
4900                    if (checked_inputs.attr('type') === 'radio') {
4901                        checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');                    
4902                    }
4903                }
4904                if (_this.parents().eq(4).hasClass('enable_correction')) {                    
4905                    if (checked_inputs.attr('type') === "radio") {
4906                        _this.parents('div[data-question-id]').find('input[name^="ays_questions"]').attr('disabled', true);
4907                        _this.parents('div[data-question-id]').find('input[name^="ays_questions"]').off('change');
4908                    } else if (checked_inputs.attr('type') === "checkbox") {
4909                        _this.attr('disabled', true);
4910                        _this.off('change');
4911                    }
4912                }
4913                return false;
4914            }
4915            if (_this.parents().eq(4).hasClass('enable_correction') && checkboxQuestionTypeFlag) {
4916                var right_answer_sound = quizContainer.find('.ays_quiz_right_ans_sound').get(0);
4917                var wrong_answer_sound = quizContainer.find('.ays_quiz_wrong_ans_sound').get(0);
4918                var finishAfterWrongAnswer = (myOptions.finish_after_wrong_answer && myOptions.finish_after_wrong_answer == "on") ? true : false;
4919                var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
4920                var explanationTime = myOptions.explanation_time && myOptions.explanation_time != "" ? parseInt(myOptions.explanation_time) : 4;
4921                var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page";
4922                var next_sibilings_count = quizContainer.find('.ays_question_count_per_page').val();
4923                var enableNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == 'on') ? true : false;
4924                var thankYouStep = quizContainer.find('div.step.ays_thank_you_fs');
4925                var infoFormLast = thankYouStep.prev().find('div.information_form');
4926                // Display all questions on one page
4927                myOptions.quiz_display_all_questions = ( myOptions.quiz_display_all_questions ) ? myOptions.quiz_display_all_questions : 'off';
4928                var quiz_display_all_questions = (myOptions.quiz_display_all_questions && myOptions.quiz_display_all_questions == "on") ? true : false;
4929
4930                var disableQuestions = false;
4931                if( parseInt( next_sibilings_count ) > 0 || quiz_display_all_questions == true ){
4932                    disableQuestions = true;
4933                }
4934
4935                myOptions.quiz_waiting_time = ( myOptions.quiz_waiting_time ) ? myOptions.quiz_waiting_time : "off";
4936                var quizWaitingTime = (myOptions.quiz_waiting_time && myOptions.quiz_waiting_time == "on") ? true : false;
4937
4938                myOptions.enable_next_button = ( myOptions.enable_next_button ) ? myOptions.enable_next_button : "off";
4939                var quizNextButton = (myOptions.enable_next_button && myOptions.enable_next_button == "on") ? true : false;
4940
4941                if ( quizWaitingTime && !quizNextButton ) {
4942                    explanationTime += 2;
4943                }
4944
4945                var quizWaitingCountDownDate = new Date().getTime() + (explanationTime * 1000);
4946
4947                if (_this.parents().eq(1).find('input[name="ays_answer_
4947correct[]"]').length !== 0) {
4948                    var checked_inputs = _this.parents().eq(1).find('input:checked');
4949                    if (checked_inputs.attr('type') === "radio") {
4950                        checked_inputs.nextAll().addClass('answered');
4951                        checked_inputs.parent().addClass('checked_answer_div');
4952                        if (checked_inputs.prev().val() == 1){
4953                            checked_inputs.nextAll().addClass('correct')
4954                            checked_inputs.parent().addClass('correct_div');
4955
4956                            if( aysThisQuizBullets !== null ){
4957                                var thisQuestionID = _this.parents('div[data-question-id]').data('questionId');
4958                                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
4959                                thisBullet.attr('disabled', 'disabled');
4960                                thisBullet.addClass('ays_quiz_correct_answer');
4961                                if (!thisBullet.parent().hasClass('ays-quiz-questions-nav-item-last-question')) {
4962                                    thisBullet.parent().addClass('ays_quiz_checked_answer_div');
4963                                }
4964                            }
4965                        }else{
4966                            checked_inputs.nextAll().addClass('wrong');
4967                            checked_inputs.parent().addClass('wrong_div');
4968
4969                            if( aysThisQuizBullets !== null ){
4970                                var thisQuestionID = _this.parents('div[data-question-id]').data('questionId');
4971                                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
4972                                thisBullet.attr('disabled', 'disabled');
4973                                thisBullet.addClass('ays_quiz_wrong_answer');
4974                                if (!thisBullet.parent().hasClass('ays-quiz-questions-nav-item-last-question')) {
4975                                    thisBullet.parent().addClass('ays_quiz_checked_answer_div');
4976                                }
4977                            }
4978                        }
4979
4980                        if (checked_inputs.prev().val() == 1) {
4981                            _this.parents('.ays-field').addClass('correct_div checked_answer_div');
4982                            _this.next('label').addClass('correct answered');
4983
4984                            if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both')){
4985                                if(! _this.parents('.step').hasClass('not_influence_to_score')){
4986                                    _this.parents().eq(3).find('.right_answer_text').slideDown(250);
4987                                }
4988                                explanationTimeout = setTimeout(function(){
4989                                    if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
4990                                        checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
4991                                        if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
4992                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
4993                                            if ( existsEmtpyQuestions ) {
4994                                                if(infoFormLast.length == 0){
4995                                                    quizContainer.find('input.ays_finish').trigger('click');
4996                                                } else {
4997                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
4998                                                }
4999                                            }
5000                                        } else {
5001                                            checked_inputs.parents('div[data-question-id]').find('.ays_
5001next').trigger('click');
5002                                        }
5003                                    } else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
5004                                        var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
5005                                        if ( existsEmtpyQuestions ) {
5006                                            if(infoFormLast.length == 0){
5007                                                quizContainer.find('input.ays_finish').trigger('click');
5008                                            } else {
5009                                                quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
5010                                            }
5011                                        }
5012                                    }
5013
5014                                }, explanationTime * 1000);
5015                                if (quizWaitingTime && !quizNextButton) {
5016                                    window.countdownTimeForShowInterval = setInterval(function () {
5017                                        countdownTimeForShow( parentStep, quizWaitingCountDownDate );
5018                                    }, 1000);
5019                                }
5020                            }else{
5021                                explanationTimeout = setTimeout(function(){
5022                                    if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
5023                                        checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
5024                                        if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
5025                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
5026                                            if ( existsEmtpyQuestions ) {
5027                                                if(infoFormLast.length == 0){
5028                                                    quizContainer.find('input.ays_finish').trigger('click');
5029                                                } else {
5030                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
5031                                                }
5032                                            }
5033                                        } else {
5034                                            checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
5035                                        }
5036                                    } else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
5037                                        var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
5038                                        if ( existsEmtpyQuestions ) {
5039                                            if(infoFormLast.length == 0){
5040                                                quizContainer.find('input.ays_finish').trigger('click');
5041                                            } else {
5042                                                quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
5043                                            }
5044                                        }
5045                                    }
5046                                }, explanationTime * 1000);
5047                                if (quizWaitingTime && !quizNextButton) {
5048                                    window.countdownTimeForShowInterval = setInterval(function () {
5049                                        countdownTimeForShow( parentStep, quizWaitingCountDownDate );
5050                                    }, 1000);
5051                                }
5052                            }
5053                            if((right_answer_sound)){
5054                                resetPlaying([right_answer_sound, wrong_answer_sound]);
5055                                setTimeout(function(){
5056                                    right_answer_sound.play();
5057                                }, 10);
5058                            }
5059                        }
5060                        else {
5061                            if(showOnlyWrongAnswer === false){
5062                                _this.parents('.ays-quiz-answers').find('input[name="ays_answer_
5062correct[]"][value="1"]').parent().addClass('correct_div checked_answer_div');
5063                                _this.parents('.ays-quiz-answers').find('input[name="ays_answer_correct[]"][value="1"]').nextAll().addClass('correct answered');
5064                                _this.parents('.ays-field').addClass('wrong_div');
5065                            }
5066
5067                            if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_passing' || myOptions.answers_rw_texts == 'on_both' || myOptions.answers_rw_texts == 'disable')){
5068                                if(! _this.parents('.step').hasClass('not_influence_to_score')){
5069                                    _this.parents().eq(3).find('.wrong_answer_text').slideDown(250);
5070                                }
5071                                if(finishAfterWrongAnswer){
5072                                    checked_inputs.parents('div[data-question-id]').find('.ays_next').attr('disabled', 'disabled');
5073                                    checked_inputs.parents('div[data-question-id]').find('.ays_early_finish').attr('disabled', 'disabled');
5074                                    checked_inputs.parents('div[data-question-id]').find('.ays_previous').attr('disabled', 'disabled');
5075                                    if( disableQuestions ){
5076                                        quizContainer.find('div[data-question-id]').css('pointer-events', 'none');
5077                                    }
5078                                }
5079                                explanationTimeout = setTimeout(function(){
5080                                    if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
5081                                        checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
5082                                        if(finishAfterWrongAnswer){
5083                                            window.aysEarlyFinishConfirmBox[ quizId ] = true;
5084                                            goToLastPage(e);
5085                                        } else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
5086                                                var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
5087                                                if ( existsEmtpyQuestions ) {
5088                                                    if(infoFormLast.length == 0){
5089                                                        quizContainer.find('input.ays_finish').trigger('click');
5090                                                    } else {
5091                                                        quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
5092                                                    }
5093                                                }
5094                                        } else{
5095                                            if ( isRequiredQuestion ) {
5096                                                var existsEmtpyQuestions = ays_quiz_is_question_empty( checked_inputs.parents('div[data-question-id]') );
5097                                                if ( existsEmtpyQuestions ) {
5098                                                    checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
5099                                                }
5100                                            } else {
5101                                                checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
5102                                            }
5103                                        }
5104                                    }else{
5105                                        if(finishAfterWrongAnswer){
5106                                            window.aysEarlyFinishConfirmBox[ quizId ] = true;
5107                                            goToLastPage(e);
5108                                        } 
5109                                        else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
5110                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
5111                                            if ( existsEmtpyQuestions ) {
5112                                                if(infoFormLast.length == 0){
5113                                                    quizContainer.find('input.ays_finish').trigger('click');
5114                                                } else {
5115                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
5116                                                }
5117                                            }
5118                                        }
5119                                    }
5120                                }, explanationTime * 1000);
5121                                if (quizWaitingTime && !quizNextButton) {
5122                                    window.countdownTimeForShowInterval = setInterval(function () {
5123                                        countdownTimeForShow( parentStep, quizWaitingCountDownDate );
5124                                    }, 1000);
5125                                }
5126                            }else{
5127                                if(finishAfterWrongAnswer){
5128                                    if( disableQuestions ){
5129                                        quizContainer.find('div[data-question-id]').css('pointer-events', 'n
5129one');
5130                                    }
5131                                }
5132
5133                                if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
5134                                    checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
5135                                    if(finishAfterWrongAnswer){
5136                                        window.aysEarlyFinishConfirmBox[ quizId ] = true;
5137                                        goToLastPage(e);
5138                                    } else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
5139                                        explanationTimeout = setTimeout(function(){
5140                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
5141                                            if ( existsEmtpyQuestions ) {
5142                                                if(infoFormLast.length == 0){
5143                                                    quizContainer.find('input.ays_finish').trigger('click');
5144                                                } else {
5145                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
5146                                                }
5147                                            }
5148                                        }, explanationTime * 1000);
5149                                        if (quizWaitingTime && !quizNextButton) {
5150                                            window.countdownTimeForShowInterval = setInterval(function () {
5151                                                countdownTimeForShow( parentStep, quizWaitingCountDownDate );
5152                                            }, 1000);
5153                                        }
5154                                    } else{
5155                                        explanationTimeout = setTimeout(function(){
5156                                            if ( isRequiredQuestion ) {
5157                                                var existsEmtpyQuestions = ays_quiz_is_question_empty( checked_inputs.parents('div[data-question-id]') );
5158                                                if ( existsEmtpyQuestions ) {
5159                                                    checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
5160                                                }
5161                                            } else {
5162                                                checked_inputs.parents('div[data-question-id]').find('.ays_next').trigger('click');
5163                                            }
5164                                        }, explanationTime * 1000);
5165                                    }
5166                                }else{
5167                                    if(finishAfterWrongAnswer){
5168                                        window.aysEarlyFinishConfirmBox[ quizId ] = true;
5169                                        goToLastPage(e);
5170                                    } 
5171                                    else if( quiz_display_all_questions && isRequiredQuestion && !enableNextButton ) {
5172                                        explanationTimeout = setTimeout(function(){
5173                                            var existsEmtpyQuestions = ays_quiz_is_question_empty( quizContainer.find('div[data-question-id]') );
5174                                            if ( existsEmtpyQuestions ) {
5175                                                if(infoFormLast.length == 0){
5176                                                    quizContainer.find('input.ays_finish').trigger('click');
5177                                                } else {
5178                                                    quizContainer.find('div[data-question-id] input.ays_next.action-button').trigger('click');
5179                                                }
5180                                            }
5181                                        }, explanationTime * 1000);
5182                                        if (quizWaitingTime && !quizNextButton) {
5183                                            window.countdownTimeForShowInterval = setInterval(function () {
5184                                                countdownTimeForShow( parentStep, quizWaitingCountDownDate );
5185                                            }, 1000);
5186                                        }
5187                                    }
5188                                }
5189                            }
5190                            if((wrong_answer_sound)){
5191                                resetPlaying([right_answer_sound, wrong_answer_sound]);
5192                                setTimeout(function(){
5193                                    wrong_answer_sound.play();
5194                                }, 10);
5195                            }
5196                            if(finishAfterWrongAnswer){
5197                                if( aysThisQuizBullets !== null ){
5198                                    aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
5199                                        var thisBullet = $(this);
5200                                        thisBullet.attr('disabled', 'disabled');
5201                                    });
5202                                }
5203                            }
5204                        }
5205
5206                        if(showExplanationOn == 'on_passing' || showExplanationOn == 'on_both'){
5207                            if(! _this.parents('.step').hasClass('not_influence_to_score')){
5208                                _this.parents().eq(3).find('.ays_questtion_explanation').slideDown(250);
5209                            }
5210                        }
5211                        _this.parents('div[data-question-id]').find('input[name^="ays_questions"]').attr('disabled', true);
5212                        _this.parents('div[data-question-id]').find('input[name^="ays_questions"]').off('change');
5213                        _this.parents('div[data-question-id]').find('.ays-field').css({
5214                            'pointer-events': 'none'
5215                        });
5216
5217                    }else if(checked_inputs.attr('type') === "checkbox"){
5218                        checked_inputs = _this;
5219                        if( _this.parents().eq(1).find('input:checked').length > 0 ){
5220                            if( aysThisQuizBullets !== null ){
5221                                var thisQuestionID = _this.parents('div[data-question-id]').data('questionId');
5222                                var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
5223                                thisBullet.parents('.ays-quiz-questions-nav-item').addClass('ays-quiz-questions-nav-item-answered');
5224                            }
5225                        }
5226
5227                        if (checked_inputs.length === 1) {
5228                            checked_inputs.parent().addClass('checked_answer_div');
5229                            if(checked_inputs.prev().val() == 1){
5230                                if((right_answer_sound)){
5231                                    resetPlaying([right_answer_sound, wrong_answer_sound]);
5232                                    setTimeout(function(){
5233                                        right_answer_sound.play();
5234                                    }, 10);
5235                                }
5236                                checked_inputs.parents('.ays-field').addClass('correct_div checked_answer_div');
5237                                checked_inputs.nextAll().addClass('correct answered');
5238                            }else{
5239                                if((wrong_answer_sound)){
5240                                    resetPlaying([right_answer_sound, wrong_answer_sound]);
5241                                    setTimeout(function(){
5242                                        wrong_answer_sound.play();
5243                                    }, 10);
5244                                }
5245                                if(finishAfterWrongAnswer){
5246                                    window.aysEarlyFinishConfirmBox[ quizId ] = true;
5247                                    goToLastPage(e);
5248                                    if( disableQuestions ){
5249                                        quizContainer.find('div[data-question-id]').css('pointer-events', 'none');
5250                                    }
5251                                    if( aysThisQuizBullets !== null ){
5252                                        aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
5253                                            var thisBullet = $(this);
5254                                            thisBullet.attr('disabled', 'disabled');
5255                                        });
5256                                    }
5257                                }
5258                                checked_inputs.parent().addClass('wrong_div');
5259                                checked_inputs.nextAll().addClass('wrong answered');
5260                            }
5261                        }else{
5262                            for (var i = 0; i < checked_inputs.length; i++) {
5263                                if(checked_inputs.eq(i).prev().val() == 1){
5264                                    if((right_answer_sound)){
5265                                        resetPlaying([right_answer_sound, wrong_answer_sound]);
5266                                        setTimeout(function(){
5267                                            right_answer_sound.play();
5268                                        }, 10);
5269                                    }
5270                                    checked_inputs.eq(i).nextAll().addClass('correct answered');
5271                                    checked_inputs.eq(i).parent().addClass('correct_div');
5272                                    checked_inputs.eq(i).parent().addClass('checked_answer_div');
5273                                }else{
5274                                    if((wrong_answer_sound)){
5275                                        resetPlaying([right_answer_sound, wrong_answer_sound]);
5276                                        setTimeout(function(){
5277                                            wrong_answer_sound.play();
5278                                        }, 10);
5279                                    }
5280                                    if(finishAfterWrongAnswer){
5281                                        window.aysEarlyFinishConfirmBox[ quizId ] = true;
5282                                        goToLastPage(e);
5283                                        if( disableQuestions ){
5284                                            quizContainer.find('div[data-question-id]').css('pointer-events', 'n
5284one');
5285                                        }
5286                                    }
5287                                    checked_inputs.eq(i).parent().addClass('checked_answer_div');
5288                                    checked_inputs.eq(i).nextAll().addClass('wrong answered');
5289                                    checked_inputs.eq(i).parent().addClass('wrong_div');
5290                                }
5291                            }
5292                            if(checked_inputs.eq(i).prev().val() == 1){
5293                                checked_inputs.eq(i).next().addClass('correct answered');
5294                                if((right_answer_sound)){
5295                                    resetPlaying([right_answer_sound, wrong_answer_sound]);
5296                                    setTimeout(function(){
5297                                        right_answer_sound.play();
5298                                    }, 10);
5299                                }
5300                            }else{
5301                                checked_inputs.eq(i).next().addClass('wrong answered');
5302                                if((wrong_answer_sound)){
5303                                    resetPlaying([right_answer_sound, wrong_answer_sound]);
5304                                    setTimeout(function(){
5305                                        wrong_answer_sound.play();
5306                                    }, 10);
5307                                }
5308                                if(finishAfterWrongAnswer){
5309                                    if( aysThisQuizBullets !== null ){
5310                                        aysThisQuizBullets.baseElement.find('.ays_questions_nav_question').each(function(){
5311                                            var thisBullet = $(this);
5312                                            thisBullet.attr('disabled', 'disabled');
5313                                        });
5314                                    }
5315                                }
5316                            }
5317                        }
5318
5319                        _this.attr('disabled', true);
5320                        _this.off('change');
5321                    }
5322                }
5323
5324                if( parentStep.data('type') === 'radio' ) {
5325                    stopQuestionTimer(quizContainer, questionID, quizId);
5326                }
5327
5328                if( aysThisQuizBullets !== null ) {
5329                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + questionID + '"]');
5330                    thisBullet.removeClass('ays-has-error');
5331                }
5332                parentStep.removeClass('ays-has-error');
5333            }else{
5334                if(_this.attr('type') === 'radio') {
5335                    _this.parents('.ays-quiz-answers').find('.checked_answer_div').removeClass('checked_answer_div');
5336                    _this.parents('.ays-field').addClass('checked_answer_div');
5337                }
5338                if(_this.attr('type') === 'checkbox') {
5339                    if(!_this.parents('.ays-field').hasClass('checked_answer_div')){
5340                        _this.parents('.ays-field').addClass('checked_answer_div');
5341                    }else{
5342                        _this.parents('.ays-field').removeClass('checked_answer_div');
5343                    }
5344                } 
5345                var checked_inputs = _this.parents().eq(1).find('input:checked');
5346                if( checked_inputs.length > 0 ){
5347                    if( aysThisQuizBullets !== null ){
5348                        var thisQuestionID = _this.parents('div[data-question-id]').data('questionId');
5349                        var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
5350                        thisBullet.parents('.ays-quiz-questions-nav-item').addClass('ays-quiz-questions-nav-item-answered');
5351                    }
5352                }else{
5353                    if( aysThisQuizBullets !== null ){
5354                        var thisQuestionID = _this.parents('div[data-question-id]').data('questionId');
5355                        var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + thisQuestionID + '"]');
5356                        thisBullet.parents('.ays-quiz-questions-nav-item').removeClass('ays-quiz-questions-nav-item-answered');
5357                    }
5358                }
5359
5360                if (checked_inputs.parents('div[data-question-id]').find('input.ays_next').hasClass('ays_display_none') &&
5361                    checked_inputs.parents('div[data-question-id]').find('i.ays_next_arrow').hasClass('ays_display_none')) {
5362                    if (checked_inputs.attr('type') === 'radio') {
5363                        checked_inputs.parents('div[data-question-id]').find('input.ays_next').trigger('click');
5364                    }
5365                }
5366
5367                if ( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
5368                    if (myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'question_timer') {
5369                        if (window.aysQuizQuestionTimers && window.aysQuizQuestionTimers[quizId]) {
5370                            if( isRequiredQuestion ) {
5371                                if (ays_quiz_is_question_empty(quizContainer.find('div[data-question-id]')) === true) {
5372                                    for (var questionId in window.aysQuizQuestionTimers[quizId]) {
5373                                        stopQuestionTimer(quizContainer, questionId, quizId);
5374                                    }
5375                                }
5376                            }else{
5377                                // for (var questionId in window.aysQuizQuestionTimers[quizId]) {
5378                                //     stopQuestionTimer(quizContainer, questionId);
5379                                // }
5380                            }
5381                        }
5382                    }
5383                }
5384
5385                if( aysThisQuizBullets !== null ) {
5386                    var thisBullet = aysThisQuizBullets.baseElement.find('.ays_questions_nav_question[data-id="' + questionID + '"]');
5387                    thisBullet.removeClass('ays-has-error');
5388                }
5389            }
5390        }
5391    });
5392
5393    function show_hide_rows(page) {
5394
5395        var rows = jQuery('table.ays-add-questions-table tbody tr');
5396        rows.each(function (index) {
5397            jQuery(this).css('display', 'none');
5398        });
5399        var counter = page * 5 - 4;
5400        for (var i = counter; i < (counter + 5); i++) {
5401            rows.eq(i - 1).css('display', 'table-row');
5402        }
5403    }
5404
5405    function createPagination(pagination, pageShow) {
5406        // (pagination, pageShow)
5407        function aysPagination(baseElement, pageShow) {
5408            this.baseElement = baseElement;
5409            this.pageShow = pageShow
5410            this.pageNow = 1
5411            var pages = this.baseElement.parents('.ays-quiz-wrap').find('div[data-question-id]').length;
5412            var pageNum = 0;
5413            var pageOffset = 0;
5414
5415            this._initNav = function() {
5416                var _this = this;
5417                if( _this.baseElement.hasClass('ays-quiz-questions-nav-with-controls') ){
5418                    var pagePos = (this.baseElement.width()/2) - (parseInt(this.baseElement.find('.ays-quiz-questions-nav-item:first-child').css('width'))/2);
5419                    _this.baseElement.find('div.ays-quiz-questions-nav-content').css({
5420                        'margin-left': pagePos,
5421                    });
5422                }
5423
5424                //init events
5425                var toPage;
5426                _this.baseElement.on('click', '.ays-quiz-questions-nav-item a.ays_questions_nav_question', function (e) {
5427                    toPage = jQuery(this).parents('.ays-quiz-questions-nav-item').index();
5428                    _this._navPage(toPage);
5429
5430                    if ('speechSynthesis' in window) {
5431                        speechSynthesis.cancel();
5432                    }
5433                });
5434
5435                if( _this.baseElement.hasClass('ays-quiz-questions-nav-with-controls') ){
5436                    _this.baseElement.on('click', '.ays-quiz-questions-nav-go-left', function (e) {
5437                        _this._navScroll(_this.pageNow, 'left');
5438                    });
5439
5440                    _this.baseElement.on('click', '.ays-quiz-questions-nav-go-right', function (e) {
5441                        _this._navScroll(_this.pageNow, 'right');
5442                    });
5443                }
5444            }
5445
5446            this._navPage = function(toPage) {
5447                this.pageNow = toPage;
5448                var sel = jQuery('.ays-quiz-questions-nav-item', this.baseElement), w = sel.first().outerWidth()+10,
5449                    diff = toPage - pageNum;
5450                var src = $(document).find('.ays-navbar-bookmark').attr('src');
5451
5452                if (toPage >= 0 && toPage <= pages - 1) {
5453                    sel.removeClass('ays-quiz-questions-nav-item-active').eq(toPage).addClass('ays-quiz-questions-nav-item-active');
5454                    if (sel.eq(toPage).find('.ays-quiz-navbar-highlighted-notice').length > 0) {
5455                        if (sel.eq(toPage).find('.ays-quiz-navbar-highlighted-notice').css('display') == 'none') {
5456                            $(document).find('.ays-navbar-bookmark').attr('highlighted', false).attr('src', src.replace('filled', 'empty'));
5457                        } else {
5458                            $(document).find('.ays-navbar-bookmark').attr('highlighted', true).attr('src', src.replace('empty', 'filled'));
5459                        }
5460                    }
5461
5462                    this.baseElement.find('[disabled]').removeAttr('disabled');
5463                    sel.eq(toPage).attr('disabled', 'disabled');
5464                    sel.eq(toPage).find('a.ays_questions_nav_question').attr('disabled', 'disabled');
5465                    pageNum = toPage;
5466                } else {
5467                    return false;
5468                }
5469
5470                if (toPage <= (pages - (this.pageShow + (diff > 0 ? 0 : 1))) && toPage >= 0) {
5471                    pageOffset = pageOffset + -w * diff;
5472                } else {
5473                    pageOffset = (toPage > 0) ? -w * (pages - this.pageShow) : 0;
5474                }
5475
5476                if( this.baseElement.hasClass('ays-quiz-questions-nav-with-controls') ){
5477                    sel.parent().css('left', pageOffset + 'px');
5478                }
5479            }
5480
5481            this._navScroll = function(toPage, dir) {
5482
5483                if(dir === 'left'){
5484                    toPage -= 3;
5485                }
5486
5487                if(dir == 'right'){
5488                    toPage += 3;
5489                }
5490
5491                if(toPage > pages - 1){
5492                    toPage = pages - 1;
5493                }
5494
5495                if(toPage < 0){
5496                    toPage = 0;
5497                }
5498
5499                this.pageNow = toPage;
5500
5501                var sel = jQuery('.ays-quiz-questions-nav-item', this.baseElement),
5502                    w = sel.first().outerWidth()+10,
5503                    diff = toPage - pageNum;
5504
5505                if (toPage >= 0 && toPage <= pages - 1) {
5506                    pageNum = toPage;
5507                } else {
5508                    return false;
5509                }
5510
5511                if (toPage <= (pages - (this.pageShow + (diff > 0 ? 0 : 1))) && toPage >= 0) {
5512                    pageOffset = pageOffset + -w * diff;
5513                } else {
5514                    pageOffset = (toPage > 0) ? -w * (pages - this.pageShow) : 0;
5515                }
5516
5517                sel.parent().css('left', pageOffset + 'px');
5518            }
5519
5520            this._initNav();
5521
5522            return this;
5523        }
5524        var bullets = new aysPagination(pagination, pageShow);
5525        
5526        return bullets;
5527    }
5528
5529})( jQuery );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.