PageSourceSearch

https://cocktailicious.nl/wp-content/plugins/quiz-maker/public/js/quiz-maker-public-ajax.js?ver=1791491615

js cocktailicious.nl collected 2026-10-08 20:34:15 UTC 120,956 bytes, 2,226 lines download raw bytes

1(function ($) {
2    'use strict';
3    $.fn.serializeFormJSON = function () {
4        var o = {},
5            a = this.serializeArray();
6        $.each(a, function () {
7            if (o[this.name]) {
8                if (!o[this.name].push) {
9                    o[this.name] = [o[this.name]];
10                }
11                o[this.name].push(this.value || '');
12            } else {
13                o[this.name] = this.value || '';
14            }
15        });
16        return o;
17    };
18    $(document).ready(function () {
19        var current_fs, next_fs, previous_fs; //fieldsets
20        var left, opacity, scale; //fieldset properties which we will animate
21        var animating; //flag to prevent quick multi-click glitches
22        var form, ays_quiz_container, ays_quiz_container_id;
23        if(!$.fn.goTo){
24            $.fn.goTo = function(myOptions) {
25                var QuizAnimationTop = (myOptions.quiz_animation_top && myOptions.quiz_animation_top != 0) ? parseInt(myOptions.quiz_animation_top) : 100;
26
27                myOptions.quiz_enable_animation_top = myOptions.quiz_enable_animation_top ? myOptions.quiz_enable_animation_top : 'on';
28                var EnableQuizAnimationTop = ( myOptions.quiz_enable_animation_top && myOptions.quiz_enable_animation_top == 'on' ) ? true : false;
29                if( EnableQuizAnimationTop ){
30                    $('html, body').animate({
31                        scrollTop: $(this).offset().top - QuizAnimationTop + 'px'
32                    }, 'slow');
33                }
34                return this; // for chaining...
35            }
36        }
37        // for details
38        $.fn.aysModal = function(action){
39            var $this = $(this);
40            switch(action){
41                case 'hide':
42                    $(this).find('.ays-modal-content').css('animation-name', 'zoomOut');
43                    setTimeout(function(){
44                        $(document.body).removeClass('modal-open');
45                        $(document).find('.ays-modal-backdrop').remove();
46                        $this.hide();
47                    }, 250);
48                    break;
49                case 'show':
50                default:
51                    $this.show();
52                    $(this).find('.ays-modal-content').css('animation-name', 'zoomIn');
53                    $(document).find('.modal-backdrop').remove();
54                    $(document.body).append('<div class="ays-modal-backdrop"></div>');
55                    $(document.body).addClass('modal-open');
56                    break;
57            }
58        }
59
60        if (!String.prototype.trim) {
61            (function() {
62                String.prototype.trim = function() {
63                    return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
64                };
65            })();
66        }
67        $(document).find(".ays-quiz-container .information_form").each(function(e){
68            var $this = $(this);
69            var cont = $(document).find(".ays-quiz-container");
70            var thisCont = $this.parents('.ays-quiz-container');
71            var quizId = thisCont.find('input[name="ays_quiz_id"]').val();
72            var myOptions = JSON.parse(window.atob(window.aysQuizOptions[quizId]));
73            if(myOptions.autofill_user_data && myOptions.autofill_user_data == "on"){
74                var userData = {};
75                userData.action = 'ays_get_user_information';
76                $.ajax({
77                    url: quiz_maker_ajax_public.ajax_url,
78                    method: 'post',
79                    dataType: 'json',
80                    data: userData,
81                    success: function (response) {
82                        if(response !== null){
83                            $this.find("input[name='ays_user_name']").val(response.data.display_name);
84                            $this.find("input[name='ays_user_email']").val(response.data.user_email);
85                        }
86                    }
87                });
88            }
89        });
90
91        $(document).on('click', '.ays-quiz-rate-link-box .ays-quiz-rate-link', function (e) {
92            e.preventDefault();
93            var _this  = $(this);
94            var parent = _this.parents('.ays-quiz-container');
95            var quizId = parent.find('input[name="ays_quiz_id"]').val();
96            var form   = parent.find('form');
97
98            var action = 'ays_get_rate_last_reviews';
99            $.ajax({
100                url: quiz_maker_ajax_public.ajax_url,
101                method: 'post',
102                dataType: 'json',
103                data: {
104                    quiz_id: quizId,
105                    action: action
106                },
107                success: function(response){
108                    if(response.status === true){
109                        form.find('.quiz_rate_reasons_body').html(response.quiz_rate_html);
110                        form.find('.lds-spinner2').addClass('lds-spinner2-none').removeClass('lds-spinner2');
111                        form.find('.quiz_rate_reasons_container').slideDown(500);
112
113                        _this.slideUp(500);
114
115                        form.on('click', 'button.ays_load_more_review', function(e){
116                            form.find('.quiz_rate_load_more [data-role="loader"]').addClass(form.find('.quiz_rate_load_more .ays-loader').data('class')).removeClass('ays-loader');
117                            var startFrom = parseInt($(e.target).attr('startfrom'));
118                            var zuyga = parseInt($(e.target).attr('zuyga'));
119                            $.ajax({
120                                url: quiz_maker_ajax_public.ajax_url,
121                                method: 'post',
122                                data:{
123                                    action: 'ays_load_more_reviews',
124                                    quiz_id: quizId,
125                                    start_from: startFrom,
126                                    zuyga: zuyga
127                                },
128                                success: function(resp){
129                                    if(zuyga == 0){
130                                        zuyga = 1;
131                                    }else{
132                                        zuyga = 0;
133                                    }
134
135                                    form.find('.quiz_rate_load_more [data-role="loader"]').addClass('ays-loader').removeClass(form.find('.quiz_rate_load_more .ays-loader').data('class'));
136                                    form.find('.quiz_rate_reasons_container').append(resp);
137                                    form.find('.quiz_rate_more_review:last-of-type').slideDown(500);
138                                    $(e.target).attr('startfrom', startFrom + 5 );
139                                    $(e.target).attr('zuyga', zuyga);
140                                    if(form.find('.quiz_rate_reasons_container p.ays_no_more').length > 0){
141                                        $(e.target).remove();
142                                    }
143                                }
144                            });
145                        });
146                    } else {
147                        swal.fire({
148                            type: 'info',
149                            html: "<h2>"+ quizLangObj.loadResource +"</h2><br><h6>"+ quizLangObj.somethingWentWrong +"</h6>"
150                        });
151                    }
152                },
153                error: function(){
154                    swal.fire({
155                        type: 'info',
156                        html: "<h2>"+ quizLangObj.loadResource +"</h2><br><h6>"+ quizLangObj.somethingWentWrong +"</h6>"
157                    });
158                }
159            });
160        });
161
162        $(document).find('input.ays_finish').on('click', function (e) {
163            e.preventDefault();
164
165            var _this = $(this);
166            ays_quiz_container_id = $(this).parents(".ays-quiz-container").attr("id");
167            ays_quiz_container = $('#'+ays_quiz_container_id);
168
169            var quizId = ays_quiz_container.find('input[name="ays_quiz_id"]').val();
170            var myOptions = JSON.parse(window.atob(window.aysQuizOptions[quizId]));
171            var quizOptionsName = 'quizOptions_'+quizId;
172            var myQuizOptions = [];
173            
174            if(typeof window[quizOptionsName] !== 'undefined'){
175                for(var i in window[quizOptionsName]){
176                    if(window[quizOptionsName].hasOwnProperty(i)){
177                        myQuizOptions[i] = (JSON.parse(window.atob(window[quizOptionsName][i])));
178                    }
179                }
180            }
181
182            var form = ays_quiz_container.find('form');
183
184            myOptions.enable_recaptcha = ( myOptions.enable_recaptcha ) ? myOptions.enable_recaptcha : 'off';
185            var quizRecaptcha = myOptions.enable_recaptcha && myOptions.enable_recaptcha == "on" ? true : false;
186
187            var formCaptchaValidation = null;
188            if( quizRecaptcha ){
189                if( form.attr('data-recaptcha-validate') ){
190                    formCaptchaValidation = form.attr('data-recaptcha-validate') == 'true' ? true : false;
191                }
192            }
193
194            if( quizRecaptcha && formCaptchaValidation === null){
195                var cEvent = new CustomEvent('afterQuizSubmission', {
196                    detail: {
197                        _this: _this,
198                        thisButton: $( e.target )
199                    }
200                });
201                form.get(0).dispatchEvent(cEvent);
202            }
203
204            if( quizRecaptcha === false ){
205                formCaptchaValidation = true;
206            }
207
208            if ( formCaptchaValidation !== true ) {
209                return;
210            }
211            
212            if( ! $(this).hasClass('ays-quiz-after-timer-end') ){
213                var confirm = true;
214                myOptions.enable_see_result_confirm_box = ! myOptions.enable_see_result_confirm_box ? 'off' : myOptions.enable_see_result_confirm_box;
215                var enable_see_result_confirm_box = (myOptions.enable_see_result_confirm_box && myOptions.enable_see_result_confirm_box == 'on') ? true : false;
216                if (enable_see_result_confirm_box) {
217                    if ( ! window.aysEarlyFinishConfirmBox[ quizId ] ) {
218                        confirm = window.confirm(quizLangObj.areYouSure);
219                        window.aysSeeResultConfirmBox[ quizId ] = false;
220                    }
221                }
222
223                if ( ! confirm ) {
224                    window.aysSeeResultConfirmBox[ quizId ] = true;
225                    return false;
226                }
227            }
228
229            if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top){
230                ays_quiz_container.goTo(myOptions);
231            }
232
233            if(ays_quiz_container.find('.ays_music_sound').length !== 0){
234                ays_quiz_container.find('.ays_music_sound').fadeOut();
235                setTimeout(function() {
236                    audioVolumeOut(ays_quiz_container.find('audio.ays_quiz_music').get(0));
237                },4000);
238                setTimeout(function() {
239                    ays_quiz_container.find('audio.ays_quiz_music').get(0).pause();
240                },6000);
241            }
242            if(ays_quiz_container.find('audio').length > 0){
243                ays_quiz_container.find('audio').each(function(e, el){
244                    el.pause();
245                });
246            }
247            if(ays_quiz_container.find('video').length > 0){
248                ays_quiz_container.find('video').each(function(e, el){
249                    el.pause();
250                });
251            }
252
253            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
254            var enableNavigationBar = (myOptions.enable_navigation_bar && myOptions.enable_navigation_bar == "on") ? true : false;
255            var aysQuestionCountPerPage = $(this).parents('form').find('.ays_question_count_per_page');
256            var next_sibilings_count = aysQuestionCountPerPage.length > 0 ? parseInt( aysQuestionCountPerPage.val() ) : null;
257
258            if( ! $(this).hasClass('ays-quiz-after-timer-end') && ! window.aysEarlyFinishConfirmBox[ quizId ] ){
259                if(isRequiredQuestion === true && next_sibilings_count !== null ){
260                    ays_quiz_is_question_required( ays_quiz_container.find('.step') );
261                    if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
262                        return false;
263                    }
264                } else if (isRequiredQuestion === true && next_sibilings_count === null) {
265                    if ( enableNavigationBar ) {
266                        ays_quiz_is_question_required( ays_quiz_container.find('.step') );
267                        if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
268                            return false;
269                        }
270                    }
271                }
272            }
273
274            ays_quiz_container.find('.ays-live-bar-wrap').addClass('bounceOut');
275            setTimeout(function () {
276                ays_quiz_container.find('.ays-live-bar-wrap').css('display','none');
277            },300);
278
279            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
280            var aysQuestionCountPerPage = $(this).parents('form').find('.ays_question_count_per_page');
281            var next_sibilings_count = aysQuestionCountPerPage.length > 0 ? parseInt( aysQuestionCountPerPage.val() ) : null;
282
283            if( ! $(this).hasClass('ays-quiz-after-timer-end') && ! window.aysEarlyFinishConfirmBox[ quizId ] ){
284                if(isRequiredQuestion === true && next_sibilings_count !== null ){
285                    ays_quiz_is_question_required( ays_quiz_container.find('.step') );
286                    if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
287                        return false;
288                    }
289                }
290            }
291
292            var emailValivatePattern = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.\w{2,}$/;
293
294            if (!($(this).hasClass('start_button'))) {
295                if ($(this).parents('.step').find('input[required]').length !== 0 ||
296                    $(this).parents('.step').find('select.ays_quiz_form_input[required]').length !== 0) {
297                    var empty_inputs = 0;
298                    var required_inputs = $(this).parents('.step').find('input[required]');
299                    $(this).parents('.step').find('.ays_red_border').removeClass('ays_red_border');
300                    $(this).parents('.step').find('.ays_green_border').removeClass('ays_green_border');
301                    for (var i = 0; i < required_inputs.length; i++) {
302                        switch(required_inputs.eq(i).attr('type')){
303                            case "checkbox": {
304                                if(required_inputs.eq(i).prop('checked') === false){
305                                    required_inputs.eq(i).addClass('ays_red_border');
306                                    required_inputs.eq(i).addClass('shake');
307                                    empty_inputs++;
308                                }else{
309                                    required_inputs.eq(i).addClass('ays_green_border');
310                                }
311                                break;
312                            }
313                            case "email": {
314                                if (!(emailValivatePattern.test(required_inputs.eq(i).val()))) {
315                                    required_inputs.eq(i).addClass('ays_red_border');
316                                    required_inputs.eq(i).addClass('shake');
317                                    empty_inputs++;
318                                }else{
319                                    required_inputs.eq(i).addClass('ays_green_border');
320                                }
321                                break;
322                            }
323                            case "tel": {
324                                if (!validatePhoneNumber(required_inputs.eq(i).get(0))) {
325                                    required_inputs.eq(i).addClass('ays_red_border');
326                                    required_inputs.eq(i).addClass('shake');
327                                    empty_inputs++;
328                                }else{
329                                    required_inputs.eq(i).addClass('ays_green_border');
330                                }
331                                break;
332                            }
333                            default:{
334                                if (required_inputs.eq(i).val() === '' &&
335                                    required_inputs.eq(i).attr('type') !== 'hidden') {
336                                    required_inputs.eq(i).addClass('ays_red_border');
337                                    required_inputs.eq(i).addClass('shake');
338                                    empty_inputs++;
339                                }else{
340                                    required_inputs.eq(i).addClass('ays_green_border');
341                                }
342                                if(required_inputs.eq(i).attr('name') == "ays_user_email" && !(emailValivatePattern.test(required_inputs.eq(i).val()))){
343                                    empty_inputs++;
344                                }
345                                break;
346                            }
347                        }
348                    }
349                    var empty_inputs2 = 0;
350                    var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]');
351                    var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]');
352                    var selectAttr = $(this).parents('.step').find('select.ays_quiz_form_input[required]');
353                    if(phoneInput.val() != ''){
354                        phoneInput.removeClass('ays_red_border');
355                        phoneInput.removeClass('ays_green_border');
356                        if (!validatePhoneNumber(phoneInput.get(0))) {
357                            if (phoneInput.attr('type') !== 'hidden') {
358                                phoneInput.addClass('ays_red_border');
359                                phoneInput.addClass('shake');
360                                empty_inputs2++;
361                            }
362                        }else{
363                            phoneInput.addClass('ays_green_border');
364                        }
365                    }
366                    if(selectAttr.val() == ''){
367                        selectAttr.removeClass('ays_red_border');
368                        selectAttr.removeClass('ays_green_border');
369
370                        selectAttr.addClass('ays_red_border');
371                        selectAttr.addClass('shake');
372                        empty_inputs++;
373                    }else{
374                        selectAttr.removeClass('ays_red_border');
375                    }
376                    var errorFields = $(this).parents('.step').find('.ays_red_border');
377                    if (empty_inputs2 !== 0 || empty_inputs !== 0) {
378                        setTimeout(function(){
379                            errorFields.each(function(){
380                                $(this).removeClass('shake');
381                            });
382                        }, 500);
383                        setTimeout(function(){
384                            required_inputs.each(function(){
385                                $(this).removeClass('shake');
386                            });
387                        }, 500);
388                        return false;
389                    }
390                }else{
391                    if($(this).parents('.step').find('.information_form').length !== 0 ){
392                        var empty_inputs = 0;
393                        var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]');
394                        var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]');
395                        var emailInputs = $(this).parents('.step').find('input[type="email"]');
396                        if(phoneInput.val() != ''){
397                            phoneInput.removeClass('ays_red_border');
398                            phoneInput.removeClass('ays_green_border');
399                            if (!validatePhoneNumber(phoneInput.get(0))){
400                                if (phoneInput.attr('type') !== 'hidden') {
401                                    phoneInput.addClass('ays_red_border');
402                                    phoneInput.addClass('shake');
403                                    empty_inputs++;
404                                }
405                            }else{
406                                phoneInput.addClass('ays_green_border');
407                            }
408                        }
409                        if(emailInput.val() != ''){
410                            emailInput.removeClass('ays_red_border');
411                            emailInput.removeClass('ays_green_border');
412                            if (!(emailValivatePattern.test(emailInput.val()))) {
413                                if (emailInput.attr('type') !== 'hidden') {
414                                    emailInput.addClass('ays_red_border');
415                                    emailInput.addClass('shake');
416                                    empty_inputs++;
417                                }
418                            }else{
419                                emailInput.addClass('ays_green_border');
420                            }
421                        }
422
423                        emailInputs.each(function(){
424                            var thisEmailInput = $(this);
425                            if(thisEmailInput.val() != ''){
426                                thisEmailInput.removeClass('ays_red_border');
427                                thisEmailInput.removeClass('ays_green_border');
428                                if (!(emailValivatePattern.test(thisEmailInput.val()))) {
429                                    thisEmailInput.addClass('ays_red_border');
430                                    thisEmailInput.addClass('shake');
431                                    empty_inputs++;
432                                }else{
433                                    thisEmailInput.addClass('ays_green_border');
434                                }
435                            }
436                        });
437                        var errorFields = $(this).parents('.step').find('.ays_red_border');
438                        if (empty_inputs !== 0) {
439                            setTimeout(function(){
440                                errorFields.each(function(){
441                                    $(this).removeClass('shake');
442                                });
443                            }, 500);
444                            return false;
445                        }
446                    }
447                }
448            }
449
450            var next_sibilings_count = $(this).parents('form').find('.ays_question_count_per_page').val();
451            $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false);
452            $(e.target).parents().eq(3).find('div.ays-quiz-timer').slideUp(500);
453            if($(e.target).parents().eq(3).find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){
454                $(e.target).parents().eq(3).find('div.ays-quiz-timer').parent().slideUp(500);
455            }
456
457            next_fs = $(this).parents('.step').next();
458            current_fs = $(this).parents('.step');
459            next_fs.addClass('active-step');
460            current_fs.removeClass('active-step');
461            form = ays_quiz_container.find('form');
462
463            if (!($(this).hasClass('start_button')) && ! window.aysEarlyFinishConfirmBox[ quizId ]) {
464                var minSelHasError = 0;
465                var buttonsDiv = current_fs.find('.ays_buttons_div');
466                var enableArrows = $(this).parents(".ays-questions-container").find(".ays_qm_enable_arrows").val();
467                var timerBox = $(this).parents(".ays-quiz-container").find(".ays-quiz-timer div.ays-quiz-after-timer");
468                if( ays_quiz_container.find('.step[data-question-id] .enable_min_selection_number').length > 0 ){
469                    ays_quiz_container.find('.step[data-question-id] .enable_min_selection_number').each(function(){
470                        var MinSelQuestion = $(this).parents('.step[data-question-id]');
471                        var checkedMinSelCount = aysCheckMinimumCountCheckbox( MinSelQuestion, myQuizOptions );
472                        if( ays_quiz_is_question_min_count( MinSelQuestion, !checkedMinSelCount ) === true ){
473                            if( checkedMinSelCount == true ){
474                                if(enableArrows){
475                                    buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled');
476                                    buttonsDiv.find('i.ays_next_arrow').prop('disabled', false);
477                                }else{
478                                    buttonsDiv.find('input.ays_next').removeAttr('disabled');
479                                    buttonsDiv.find('input.ays_next').prop('disabled', false);
480                                }
481                            }else{
482                                if(enableArrows){
483                                    buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
484                                    buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
485                                    buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
486                                }else{
487                                    buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
488                                    buttonsDiv.find('input.ays_next').prop('disabled', true);
489                                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
490                                }
491                                minSelHasError++;
492                            }
493                        }else{
494                            if(enableArrows){
495                                buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
496                                buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
497                                buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
498                            }else{
499                                buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
500                                buttonsDiv.find('input.ays_next').prop('disabled', true);
501                                buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
502                            }
503                            minSelHasError++;
504                        }
505                    });
506                }
507
508                var is_timerEnd = false;
509                if(timerBox.hasClass("ays_timer_end")){
510                    is_timerEnd = true;
511                }
512
513                if( minSelHasError > 0 && is_timerEnd){
514                    return false;
515                }
516            }
517
518            var textAnswers = form.find('div.ays-text-field textarea.ays-text-input');
519            for(var i=0; i < textAnswers.length; i++){
520                var userAnsweredText = textAnswers.eq(i).val().trim();
521                var questionId = textAnswers.eq(i).parents('.step').data('questionId');
522
523                var trueAnswered = false;
524
525                // Enable case sensitive text
526                var enable_case_sensitive_text = (myQuizOptions[questionId].enable_case_sensitive_text && myQuizOptions[questionId].enable_case_sensitive_text != "") ? myQuizOptions[questionId].enable_case_sensitive_text : false;
527
528                var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer == '' ? "" : myQuizOptions[questionId].question_answer;
529                var thisQuestionAnswer = thisQuestionCorrectAnswer.toLowerCase();
530
531                if ( enable_case_sensitive_text ) {
532                    thisQuestionAnswer = thisQuestionCorrectAnswer;
533                }
534
535                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes().split('%%%');
536                for(var i_answer = 0; i_answer < thisQuestionAnswer.length; i_answer++){
537                    if ( enable_case_sensitive_text ) {
538                        if(userAnsweredText == thisQuestionAnswer[i_answer].trim()){
539                            trueAnswered = true;
540                            break;
541                        }
542                    } else {
543                        if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i_answer].trim()){
544                            trueAnswered = true;
545                            break;
546                        }
547                    }
548                }
549
550                if(trueAnswered){
551                    textAnswers.eq(i).next().val(1);
552                }else{
553                    textAnswers.eq(i).next().val(0);
554                    if(thisQuestionCorrectAnswer == ''){
555                        textAnswers.eq(i).attr('chishtpatasxan', '-');
556                    }else{
557                        textAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer);
558                    }
559                }
560                textAnswers.eq(i).removeAttr('disabled');
561            }
562            
563            var numberAnswers = form.find('div.ays-text-field input[type="number"].ays-text-input');
564            for(var i=0; i < numberAnswers.length; i++){
565                var userAnsweredText = numberAnswers.eq(i).val().trim();
566                var questionId = numberAnswers.eq(i).parents('.step').data('questionId');
567                if(userAnsweredText.toLowerCase() === myQuizOptions[questionId].question_answer.toLowerCase()){
568                    numberAnswers.eq(i).next().val(1);
569                }else{
570                    numberAnswers.eq(i).next().val(0);
571                    numberAnswers.eq(i).attr('chishtpatasxan', myQuizOptions[questionId].question_answer);
572                }
573                numberAnswers.eq(i).removeAttr('disabled')
574            }
575            
576            var shortTextAnswers = form.find('div.ays-text-field input[type="text"].ays-text-input');
577            for(var i=0; i < shortTextAnswers.length; i++){
578                var userAnsweredText = shortTextAnswers.eq(i).val().trim();
579                var questionId = shortTextAnswers.eq(i).parents('.step').data('questionId');
580
581                var trueAnswered = false;
582
583                // Enable case sensitive text
584                var enable_case_sensitive_text = (myQuizOptions[questionId].enable_case_sensitive_text && myQuizOptions[questionId].enable_case_sensitive_text != "") ? myQuizOptions[questionId].enable_case_sensitive_text : false;
585
586                var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer == '' ? "" : myQuizOptions[questionId].question_answer;
587                var thisQuestionAnswer = thisQuestionCorrectAnswer.toLowerCase();
588
589                if ( enable_case_sensitive_text ) {
590                    thisQuestionAnswer = thisQuestionCorrectAnswer;
591                }
592
593                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes().split('%%%');
594                for(var i_answer = 0; i_answer < thisQuestionAnswer.length; i_answer++){
595                    if ( enable_case_sensitive_text ) {
596                        if(userAnsweredText == thisQuestionAnswer[i_answer].trim()){
597                            trueAnswered = true;
598                            break;
599                        }
600                    } else {
601                        if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i_answer].trim()){
602                            trueAnswered = true;
603                            break;
604                        }
605                    }
606                }
607
608                if(trueAnswered){
609                    shortTextAnswers.eq(i).next().val(1);
610                }else{
611                    shortTextAnswers.eq(i).next().val(0);
612                    if(thisQuestionCorrectAnswer == ''){
613                        shortTextAnswers.eq(i).attr('chishtpatasxan', '-');
614                    }else{
615                        shortTextAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer);
616                    }
617                }
618
619                shortTextAnswers.eq(i).removeAttr('disabled')
620            }
621
622            var dateAnswers = form.find('div.ays-text-field input[type="date"].ays-text-input');
623            for(var i=0; i < dateAnswers.length; i++){
624                var userAnsweredText = dateAnswers.eq(i).val();
625                var questionId = dateAnswers.eq(i).parents('.step').data('questionId');
626                var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer == '' ? "" : myQuizOptions[questionId].question_answer;
627
628                var trueAnswered = false;
629                var correctDate = new Date(thisQuestionCorrectAnswer),
630                    correctDateYear = correctDate.getFullYear(),
631                    correctDateMonth = correctDate.getMonth(),
632                    correctDateDay = correctDate.getDate();
633                var userDate = new Date(userAnsweredText),
634                    userDateYear = userDate.getFullYear(),
635                    userDateMonth = userDate.getMonth(),
636                    userDateDay = userDate.getDate();
637
638                if(correctDateYear == userDateYear && correctDateMonth == userDateMonth && correctDateDay == userDateDay){
639                    trueAnswered = true;
640                }
641
642                if(trueAnswered){
643                    dateAnswers.eq(i).next().val(1);
644                }else{
645                    dateAnswers.eq(i).next().val(0);
646                    if(thisQuestionCorrectAnswer == ''){
647                        dateAnswers.eq(i).attr('chishtpatasxan', '-');
648                    }else{
649                        dateAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer);
650                    }
651                }
652
653                dateAnswers.eq(i).removeAttr('disabled')
654            }
655
656
657            var data = form.serializeFormJSON();
658            var questionsIds = data.ays_quiz_questions.split(',');
659            
660            for(var i = 0; i < questionsIds.length; i++){
661                if(! data['ays_questions[ays-question-'+questionsIds[i]+']']){
662                    data['ays_questions[ays-question-'+questionsIds[i]+']'] = "";
663                }
664            }
665            
666            $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').css("display", "none");
667
668            data.action = 'ays_finish_quiz';
669            data.end_date = GetFullDateTime();
670            var ays_quiz_finish_time = ays_quiz_container.find('.ays-quiz-end-date');
671            if ( ays_quiz_finish_time.length !== 0 && ays_quiz_finish_time.val() != "" ) {
672                data.end_date = ays_quiz_finish_time.val();
673            } else {
674                data.end_date = GetFullDateTime();
675            }
676
677            if ( typeof data.start_date == "undefined" || data.start_date == "" ) {
678                data.start_date = window.aysQuizStartDate;
679            }
680
681            if ( typeof data.end_date == "undefined" || data.end_date == "" ) {
682                data.end_date = GetFullDateTime();
683            }
684            
685            var aysQuizLoader = form.find('div[data-role="loader"]');
686            aysQuizLoader.addClass(aysQuizLoader.data('class'));
687            aysQuizLoader.removeClass('ays-loader');
688
689            var animationOptions = {
690                scale: scale,
691                left: left,
692                opacity: opacity,
693                animating: animating
694            }
695            
696            setTimeout(function () {
697                sendQuizData(data, form, myOptions, animationOptions, $(e.target));
698            },2000);
699            
700            if (parseInt(next_sibilings_count) > 0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))) {
701                current_fs = $(this).parents('form').find('div[data-question-id]');
702            }
703            
704//            aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
705        });
706
707        $(document).find('.ays_next.start_button').on('click',function(e){
708            var $this = $(this);
709            var thisCont = $this.parents('.ays-quiz-container');
710            var quizId = thisCont.find('input[name="ays_quiz_id"]').val();
711            var myOptions = JSON.parse(window.atob(window.aysQuizOptions[quizId]));
712            var checkQuizGeneratedPassword = checkQuizPassword(e, myOptions, false);
713            if(checkQuizGeneratedPassword){
714                if(myOptions.enable_password && myOptions.enable_password == 'on'){
715                    if(myOptions.generate_password && myOptions.generate_password == 'generated_password'){
716                        var userGeneratedPasswordVal = $this.parents('.ays-quiz-container').find('.ays_quiz_password').val();
717                        var userData = {};
718                        userData.action = 'ays_generated_used_passwords';
719                        userData.userGeneratedPassword = userGeneratedPasswordVal;
720                        userData.quizId = quizId;
721                        $.ajax({
722                            url: quiz_maker_ajax_public.ajax_url,
723                            method: 'post',
724                            dataType: 'json',
725                            data: userData,
726                            success: function (response) {
727                                if(response.status){
728                                }
729                            }
730                        });
731                    }
732                }
733
734                if(myOptions.limit_users && myOptions.limit_users == 'on'){
735                    var limit_users_by = (myOptions.limit_users_by && myOptions.limit_users_by != '') ? myOptions.limit_users_by : 'ip';
736                    var isUserLoggedIn = (myOptions.is_user_logged_in && myOptions.is_user_logged_in != null) ? myOptions.is_user_logged_in : null;
737
738                    myOptions.enable_restriction_pass = myOptions.enable_restriction_pass ? myOptions.enable_restriction_pass : 'off';
739                    var onlyForSelectedUserRole = (myOptions.enable_restriction_pass && myOptions.enable_restriction_pass == 'on' ) ? true : false;
740
741                    myOptions.turn_on_extra_security_check = myOptions.turn_on_extra_security_check ? myOptions.turn_on_extra_security_check : 'on';
742                    var turnOnSecurityCheck = (myOptions.turn_on_extra_security_check && myOptions.turn_on_extra_security_check == 'on' ) ? true : false;
743
744                    myOptions.limit_attempts_count_by_user_role = myOptions.limit_attempts_count_by_user_role ? myOptions.limit_attempts_count_by_user_role : '';
745                    var limitAttemptsCountByUserRole = (myOptions.limit_attempts_count_by_user_role !=='' ) ? parseInt( myOptions.limit_attempts_count_by_user_role ) : '';
746
747                    if( isUserLoggedIn === null ){
748                        isUserLoggedIn = false;
749                    }
750
751                    var checkLimit = false;
752                    if( limit_users_by != 'user_id' ){
753                        checkLimit = true;
754                    }
755
756                    if( isUserLoggedIn ){
757                        checkLimit = true;
758                    }
759
760                    if( turnOnSecurityCheck === false ){
761                        checkLimit = false;
762                    }
763
764                    if( checkLimit ){
765                        var quiz_max_pass_count = (myOptions.quiz_max_pass_count && myOptions.quiz_max_pass_count != '') ? parseInt(myOptions.quiz_max_pass_count) : 1;
766
767                        if( limitAttemptsCountByUserRole !== '' && onlyForSelectedUserRole === true ){
768                            quiz_max_pass_count = limitAttemptsCountByUserRole;
769                        }
770
771                        var limitation_message = (myOptions.limitation_message && myOptions.limitation_message != '') ? myOptions.limitation_message : quizLangObj.alreadyPassedQuiz;
772                        var quiz_pass_score = (myOptions.quiz_pass_score && myOptions.quiz_pass_score != '') ? myOptions.quiz_pass_score : 0;
773                        var text_color = (myOptions.text_color && myOptions.text_color != '') ? myOptions.text_color : "#333";
774
775                        var html = '<div style="color:'+ text_color +';min-height:200px;" class="ays_block_content">'+ limitation_message +'</div>';
776
777                        var userData = {};
778
779                        userData.action = 'ays_quiz_check_user_started';
780                        userData.quiz_id = quizId;
781                        userData.quiz_max_pass_count = quiz_max_pass_count;
782                        userData.quiz_pass_score = quiz_pass_score;
783                        userData.start_date = GetFullDateTime();
784
785                        $.ajax({
786                            url: quiz_maker_ajax_public.ajax_url,
787                            method: 'post',
788                            dataType: 'json',
789                            data: userData,
790                            success: function (response) {
791                                if(response.status){
792                                    thisCont.find('.ays_quiz_result_row_id').val(response.result_id);
793                                }else{
794                                    $this.parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').hide();
795                                    thisCont.find('.ays_quiz_timer_container').slideUp(500);
796                                    thisCont.find('form').append(html);
797                                    thisCont.find('div.step').remove();
798                                    clearInterval(window.aysTimerInterval);
799                                }
800                            }
801                        });
802                    }
803                }
804                else if( myOptions.store_all_not_finished_results && myOptions.store_all_not_finished_results === true ){
805                    var quiz_max_pass_count = (myOptions.quiz_max_pass_count && myOptions.quiz_max_pass_count != '') ? parseInt(myOptions.quiz_max_pass_count) : 1;
806                    var limitation_message = (myOptions.limitation_message && myOptions.limitation_message != '') ? myOptions.limitation_message : quizLangObj.alreadyPassedQuiz;
807                    var quiz_pass_score = (myOptions.quiz_pass_score && myOptions.quiz_pass_score != '') ? myOptions.quiz_pass_score : 0;
808                    var text_color = (myOptions.text_color && myOptions.text_color != '') ? myOptions.text_color : "#333";
809
810                    var html = '<div style="color:'+ text_color +';min-height:200px;" class="ays_block_content">'+ limitation_message +'</div>';
811
812                    var userData = {};
813
814                    userData.action = 'ays_quiz_check_user_started';
815                    userData.quiz_id = quizId;
816                    userData.quiz_max_pass_count = quiz_max_pass_count;
817                    userData.quiz_pass_score = quiz_pass_score;
818                    userData.start_date = GetFullDateTime();
819
820                    $.ajax({
821                        url: quiz_maker_ajax_public.ajax_url,
822                        method: 'post',
823                        dataType: 'json',
824                        data: userData,
825                        success: function (response) {
826                            if(response.status){
827                                thisCont.find('.ays_quiz_result_row_id').val(response.result_id);
828                            }else{
829                                clearInterval(window.aysTimerInterval);
830                            }
831                        }
832                    });
833                }
834            }
835
836            if( myOptions.paypalStatus ){
837                if( myOptions.paypalStatus.extraCheck === true ){
838                    var userData = {};
839
840                    userData.action = 'ays_quiz_check_user_started_for_paypal';
841                    userData.quiz_id = quizId;
842                    userData.order_id = myOptions.paypalStatus.orderId;
843                    userData.start_date = GetFullDateTime();
844
845                    $.ajax({
846                        url: quiz_maker_ajax_public.ajax_url,
847                        method: 'post',
848                        dataType: 'json',
849                        data: userData
850                    });
851                }
852            }
853        });
854
855    });
856    
857    function sendQuizData(data, form, myOptions, options, element){
858        if(typeof sendQuizData.counter == 'undefined'){
859            sendQuizData.counter = 0;
860        }
861        if(window.navigator.onLine){
862            sendQuizData.counter++;
863            $.ajax({
864                url: window.quiz_maker_ajax_public.ajax_url,
865                method: 'post',
866                dataType: 'json',
867                data: data,
868                success: function(response){
869                    if(response.status === true){
870                        doQuizResult(response, form, myOptions);
871                    }else if( response.status === false && typeof response.flag !== 'undefined' && response.flag === false ){
872                        var aysQuizContainer = element.parents('.ays-quiz-container');
873                        var lastPageContent = '';
874
875                        lastPageContent += '<p>';
876                            lastPageContent += response.text;
877                        lastPageContent += '</p>';
878
879                        aysQuizContainer.find('.ays_thank_you_fs').html( lastPageContent );
880                    }else{
881                        if(sendQuizData.counter >= 5){
882                            swal.fire({
883                                type: 'error',
884                            html: quizLangObj.sorry + ".<br>" + quizLangObj.unableStoreData + "."
885                            });
886                            goQuizFinishPage(form, options, element, myOptions);
887                        }else{
888                            if(window.navigator.onLine){
889                                setTimeout(function(){
890                                    sendQuizData(data, form, myOptions, options, element);
891                                },3000);
892                            }else{
893                                sendQuizData(data, form, myOptions, options, element);
894                            }
895                        }
896                    }
897                },
898                error: function(jqXHR, textStatus, errorThrown) {
899                    if(sendQuizData.counter >= 5){
900                        swal.fire({
901                            type: 'error',
902                            html: quizLangObj.sorry + ".<br>" + quizLangObj.unableStoreData + "."
903                        });
904                        goQuizFinishPage(form, options, element, myOptions);
905                    }else{
906                        setTimeout(function(){
907                            sendQuizData(data, form, myOptions, options, element);
908                        },3000);
909                    }
910                }
911            });
912        }else{
913            swal.fire({
914                type: 'warning',
915                html: quizLangObj.connectionLost + ".<br>" + quizLangObj.checkConnection + "."
916            });
917            sendQuizData.counter = 0;
918            goQuizFinishPage(form, options, element, myOptions);
919            var aysQuizContainer = element.parents('.ays-quiz-container');
920            aysQuizContainer.find('.step').hide();
921            aysQuizContainer.find('.ays_thank_you_fs').prev().removeAttr('style').css({
922                'display':'flex',
923                'position':'static',
924                'transform':'scale(1)',
925                'opacity': 1,
926                'pointer-events': 'auto'
927            });
928            var show_result_button = element.parents('form').find('div[data-question-id] input[name="ays_finish_quiz"]');
929            if (show_result_button.hasClass('ays_display_none')) {
930                show_result_button.removeClass('ays_display_none');
931            }
932        }
933    }
934    
935    function goQuizFinishPage(form, options, element, myOptions){        
936        var currentFS = form.find('.step.active-step');
937        var next_sibilings_count = form.find('.ays_question_count_per_page').val();
938        if (parseInt(next_sibilings_count) > 0 &&
939            (element.parents('.step').attr('data-question-id') ||
940             element.parents('.step').next().attr('data-question-id'))) {
941            currentFS = form.find('div[data-question-id]');
942        }
943        currentFS.prev().css('display', 'flex');
944        currentFS.animate({opacity: 0}, {
945            step: function(now, mx) {
946                options.scale = 1 - (1 - now) * 0.2;
947                options.left = (now * 50)+"%";
948                options.opacity = 1 - now;
949                currentFS.css({
950                    'transform': 'scale('+options.scale+')',
951                    'position': '',
952                    'pointer-events': 'none'
953                });
954                currentFS.prev().css({
955                    'left': options.left,
956                    'opacity': options.opacity,
957                    'pointer-events': 'none'
958                });
959            },
960            duration: 800,
961            complete: function(){
962                currentFS.hide();
963                currentFS.css({
964                    'opacity': '1',
965                    'pointer-events': 'auto',
966                });
967                currentFS.prev().css({
968                    'transform': 'scale(1)',
969                    'position': 'relative',
970                    'opacity': '1',
971                    'pointer-events': 'auto'
972                });
973                options.animating = false;
974            },
975            easing: 'easeInOutBack'
976        });
977        if(myOptions.enable_correction == 'on'){
978            if(currentFS.prev().find('input:checked').length > 0){
979                currentFS.prev().find('.ays-field input').attr('disabled', 'disabled');
980                currentFS.prev().find('.ays-field input').on('click', function(){
981                    return false;
982                });
983                currentFS.prev().find('.ays-field input').on('change', function(){
984                    return false;
985                });
986            }
987            if(currentFS.prev().find('option:checked').length > 0){
988                currentFS.prev().find('.ays-field select').attr('disabled', 'disabled');
989                currentFS.prev().find('.ays-field select').on('click', function(){
990                    return false;
991                });
992                currentFS.prev().find('.ays-field select').on('change', function(){
993                    return false;
994                });
995            }
996            if(currentFS.prev().find('textarea').length > 0){
997                if(currentFS.prev().find('textarea').val() !== ''){
998                    currentFS.prev().find('.ays-field textarea').attr('disabled', 'disabled');
999                    currentFS.prev().find('.ays-field textarea').on('click', function(){
1000                        return false;
1001                    });
1002                    currentFS.prev().find('.ays-field textarea').on('change', function(){
1003                        return false;
1004                    });
1005                }
1006            }
1007        }
1008    }
1009    
1010    function doQuizResult(response, form, myOptions){
1011        var hideQuizBGImage = form.parents('.ays-quiz-container').data('hideBgImage');
1012		var QuizBGGragient = form.parents('.ays-quiz-container').data('bgGradient');
1013        var quizId = form.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
1014		if(hideQuizBGImage){
1015			form.parents('.ays-quiz-container').css('background-image', 'none');
1016			if(typeof QuizBGGragient != 'undefined'){
1017				form.parents('.ays-quiz-container').css('background-image', QuizBGGragient);
1018			}
1019		}
1020
1021        if(typeof response.chain_quiz_button_text != 'undefined' && response.chain_quiz_button_text === 'seeResult'){
1022            form.find('.ays_chain_see_result_button').removeClass('ays_display_none');
1023        }else if(typeof response.chain_quiz_button_text != 'undefined' && response.chain_quiz_button_text === 'nextQuiz'){
1024            form.find('.ays_chain_next_quiz_button').removeClass('ays_display_none');
1025        }
1026
1027        var conditionsData = response.conditionData;
1028        var conditionsExict = false;
1029        var conditionPageMessage = "";
1030        var conditionEmailMessage = "";
1031        var conditionRedirectDelay = "";
1032        var conditionRedirectUrl = "";
1033        var conditionRedirectCountDown = "";
1034        var trueConditionsCount = "";
1035        if(typeof conditionsData != "undefined"){
1036            if(conditionsData.hasAction){
1037                if(conditionsData.pageMessage){
1038                    conditionPageMessage = conditionsData.pageMessage;
1039                }
1040                if(conditionsData.emailMessage){
1041                    conditionEmailMessage = conditionsData.emailMessage;
1042                }
1043                if(conditionsData.redirectDelay){
1044                    conditionRedirectDelay = conditionsData.redirectDelay;
1045                }
1046                if(conditionsData.redirectUrl){
1047                    conditionRedirectUrl = conditionsData.redirectUrl;
1048                }
1049                if(conditionsData.redirectCountDown){
1050                    conditionRedirectCountDown = conditionsData.redirectCountDown;
1051                }
1052                if(conditionsData.trueConditionsCount){
1053                    trueConditionsCount = conditionsData.trueConditionsCount;
1054                }
1055                conditionsExict = true;
1056            }
1057        }
1058
1059        var ays_block_element = form.parents('.ays-quiz-container');
1060        var redirectActionResponse = true;
1061        if(conditionsExict){
1062            if(conditionRedirectUrl){
1063                redirectActionResponse = redirectAction(conditionRedirectUrl, conditionRedirectDelay, ays_block_element, conditionRedirectCountDown, form, myOptions, false);
1064            }else{
1065                if(response.showIntervalMessage && ( response.interval_redirect_url !== null && response.interval_redirect_url != '' )){
1066                    redirectActionResponse = redirectAction(response.interval_redirect_url, response.interval_redirect_delay, ays_block_element, response.interval_redirect_after, form, myOptions, false);
1067                }else{
1068                    if (myOptions.redirect_after_submit && myOptions.redirect_after_submit == 'on') {
1069                        redirectActionResponse = redirectAction(myOptions.submit_redirect_url, myOptions.submit_redirect_delay, ays_block_element, myOptions.submit_redirect_after, form, myOptions, true);
1070                    }
1071                }
1072            }
1073        }else{
1074            if(response.showIntervalMessage && ( response.interval_redirect_url !== null && response.interval_redirect_url != '' )){
1075                redirectActionResponse = redirectAction(response.interval_redirect_url, response.interval_redirect_delay, ays_block_element, response.interval_redirect_after, form, myOptions, false);
1076            }else{
1077                if (myOptions.redirect_after_submit && myOptions.redirect_after_submit == 'on') {
1078                    redirectActionResponse = redirectAction(myOptions.submit_redirect_url, myOptions.submit_redirect_delay, ays_block_element, myOptions.submit_redirect_after, form, myOptions, true);
1079                }
1080            }
1081        }
1082
1083        if( redirectActionResponse === false ){
1084            return false;
1085        }
1086
1087        form.find('div.ays_message').css('display', 'none');
1088        form.find('.ays_average').css({'display': 'block'});
1089        var quizScore = '';
1090        switch(response.displayScore){
1091            case 'by_percentage':
1092                quizScore = parseInt(response.score);
1093            break;
1094            case 'by_correctness':
1095                quizScore = response.score.split('/');
1096            break;
1097            case 'by_points':
1098                quizScore = response.score.split('/');
1099            break;
1100            default:
1101                quizScore = parseInt(response.score);
1102        }
1103
1104        if (response.hide_result) {
1105            form.find('div.ays_message').html(response.text);
1106        } else {
1107            if(response.showIntervalMessage){
1108                form.find('div.ays_message').html(response.intervalMessage + response.finishText);
1109                if (response.product) {
1110//                    var $wooBlock = $("<div class='ays-woo-block'></div>");
1111//                    var $wooInBlock = $("<div class='ays-woo-product-block'></div>");
1112//                    var $wooImage = $('<div class="product-image"><img src="' + response.product.image + '" alt="WooCommerce Product"></div>');
1113//                    var $wooName = $('<h4 class="ays-woo-product-title"><a href="'+response.product.prodUrl+'" target="_blank">'+response.product.name+'</a></h4>');
1114//                    var $wooCartLink = $(response.product.link);
1115//                    if(response.product.image){
1116//                        $wooBlock.append($wooImage);
1117//                    }
1118//                    $wooInBlock.append($wooName);
1119//                    $wooInBlock.append($wooCartLink);
1120//                    $wooBlock.append($wooInBlock);
1121//                    form.find('div.ays_message').after($wooBlock);
1122//                    if(form.parents('.ays-quiz-container').width() < 420){
1123//                        form.find('.ays-woo-block').css('flex-wrap', 'wrap');
1124//                        if(response.product.image){
1125//                            form.find('.ays-woo-product-block').css('padding-top', '20px');
1126//                        }
1127//                    }
1128                    var $wooBlock = '';
1129                    var $wooInBlock = '';
1130                    var $wooImage = '';
1131                    var $wooName = '';
1132                    var $wooCartLink = '';
1133                    var $wooBloks = '';
1134                    $wooBloks = $("<div class='ays-woo-block-main'></div>")
1135                    for(var products in response.product){
1136                        $wooBlock    = $("<div class='ays-woo-block'></div>");
1137                        $wooInBlock  = $("<div class='ays-woo-product-block'></div>");
1138                        $wooImage    = $('<div class="product-image"><img src="' + response.product[products].image + '" alt="WooCommerce Product"></div>');
1139                        $wooName     = $('<h4 class="ays-woo-product-title"><a href="'+response.product[products].prodUrl+'" target="_blank">'+response.product[products].name+'</a></h4>');
1140                        $wooCartLink = $(response.product[products].link);
1141                        if(response.product[products].image){
1142                            $wooBlock.append($wooImage);
1143                        }
1144                        $wooBloks.append($wooBlock);
1145                        $wooInBlock.append($wooName);
1146                        $wooInBlock.append($wooCartLink);
1147                        $wooBlock.append($wooInBlock);
1148                        form.find('div.ays_message').after($wooBloks);
1149                        if(form.parents('.ays-quiz-container').width() < 420){
1150                            form.find('.ays-woo-block').css('flex-wrap', 'wrap');
1151                            if(response.product[products].image){
1152                                form.find('.ays-woo-product-block').css('padding-top', '20px');
1153                            }
1154                        }
1155                    }
1156                }
1157            }else{
1158                form.find('div.ays_message').html(response.finishText);
1159            }
1160
1161            if(conditionsExict){
1162                form.find('div.ays_message').prepend(conditionPageMessage);
1163            }
1164
1165            form.find('p.ays_score').removeClass('ays_score_display_none');
1166            form.find('p.ays_score').html(form.find('p.ays_score').text()+'<span class="ays_score_percent animated"> ' + response.score + '</span>');
1167        }
1168        form.find('div.ays_message').fadeIn(500);
1169        setTimeout(function () {
1170            form.find('p.ays_score').addClass('tada');
1171        }, 500);
1172        var numberOfPercent = 0;
1173        var percentAnimate = setInterval(function(){
1174            if(typeof quizScore == 'number'){
1175                form.find('.ays-progress-value').text(numberOfPercent + "%");
1176                if(numberOfPercent == quizScore){
1177                    clearInterval(percentAnimate);
1178                }
1179                numberOfPercent++;
1180            }else{
1181                var total = quizScore[1];
1182                var count = quizScore[0];
1183                total = parseFloat(total.trim());
1184                count = parseFloat(count.trim());
1185                form.find('.ays-progress-value').text(numberOfPercent + " / " + total);
1186                if(numberOfPercent >= count){
1187                    form.find('.ays-progress-value').text(count + " / " + total);
1188                    clearInterval(percentAnimate);
1189                }
1190                numberOfPercent++;
1191            }
1192        },20);
1193        
1194        var score = quizScore;
1195        if(response.displayScore == 'by_correctness' || response.displayScore == 'by_points'){
1196            var total = parseInt(quizScore[1].trim());
1197            var count = parseInt(quizScore[0].trim());
1198            score = (count / total) * 100;
1199        }
1200
1201        if(response.scoreMessage){
1202            form.find('div.ays_score_message').html(response.scoreMessage);
1203        }
1204
1205        var last_result_id = null;
1206        if(response.result_id && response.result_id != ''){
1207            last_result_id = parseInt( response.result_id );
1208        }
1209
1210        aysQuizSetCustomEvent();
1211        var trackUsersEvent = new CustomEvent('getResultId', {
1212            detail: {
1213              resultId: last_result_id
1214            }
1215        });
1216        form.get(0).dispatchEvent(trackUsersEvent);
1217
1218        // Make responses anonymous
1219        myOptions.quiz_make_responses_anonymous = ( myOptions.quiz_make_responses_anonymous ) ? myOptions.quiz_make_responses_anonymous : 'off';
1220        var quiz_make_responses_anonymous = (myOptions.quiz_make_responses_anonymous && myOptions.quiz_make_responses_anonymous == "on") ? true : false;
1221
1222        if(score > 0){
1223            form.find('.ays-progress-bar').css('padding-right', '7px');
1224            var progressBarStyle = myOptions.progress_bar_style ? myOptions.progress_bar_style : 'first';
1225            if(progressBarStyle == 'first' || progressBarStyle == 'second'){
1226                form.find('.ays-progress-value').css('width', 0);
1227                form.find('.ays-progress-value').css('transition', 'width ' + score*25 + 'ms linear');
1228                setTimeout(function(){
1229                    form.find('.ays-progress-value').css('width', score+'%');
1230                }, 1);
1231            }
1232            form.find('.ays-progress-bar').css('transition', 'width ' + score*25 + 'ms linear');
1233            setTimeout(function(){
1234                form.find('.ays-progress-bar').css('width', score+'%');
1235            }, 1);
1236        }
1237
1238        if ( score == 0 ) {
1239            // Quiz background Color
1240            var quiz_make_bg_color = (myOptions.bg_color && myOptions.bg_color != "") ? myOptions.bg_color : '#fff';
1241
1242            form.find('.ays-progress-value').css('color', quiz_make_bg_color);
1243        }
1244
1245        form.append($("<div class='ays_quiz_results'></div>"));
1246        var formResults = form.find('.ays_quiz_results');
1247        if (form.hasClass('enable_questions_result')) {
1248
1249            // Enable the Show/Hide toggle
1250            myOptions.quiz_enable_results_toggle = ! myOptions.quiz_enable_results_toggle ? 'off' : myOptions.quiz_enable_results_toggle;
1251            var quiz_enable_results_toggle = (myOptions.quiz_enable_results_toggle && myOptions.quiz_enable_results_toggle == 'on') ? true : false;
1252
1253            var resultToggleHTML = "";
1254
1255            resultToggleHTML += '<div class="ays-quiz-results-toggle-block">';
1256                resultToggleHTML += '<span class="ays-show-res-toggle ays-res-toggle-show">'+ quizLangObj.show +'</span>';
1257                resultToggleHTML += '<input type="checkbox" class="ays_toggle ays_toggle_slide ays-quiz-res-toggle-checkbox" id="ays-quiz-show-results-toggle-'+ quizId +'" checked>';
1258                resultToggleHTML += '<label for="ays-quiz-show-results-toggle-'+ quizId +'" class="ays_switch_toggle">Toggle</label>';
1259                resultToggleHTML += '<span class="ays-show-res-toggle ays-res-toggle-hide quest-toggle-failed">'+ quizLangObj.hide +'</span>';
1260            resultToggleHTML += '</div>';
1261
1262            if ( quiz_enable_results_toggle ) {
1263                formResults.append(resultToggleHTML);
1264            }
1265
1266            var questions = form.find('div[data-question-id]');
1267            var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
1268            if(myOptions.enable_correction && myOptions.enable_correction != 'on'){
1269                showOnlyWrongAnswer = false;
1270            }
1271            var answerIsRightArr = new Array();
1272            for (var z = 0; z < questions.length; z++) {                
1273                if(questions.eq(z).hasClass('not_influence_to_score')){
1274                    continue;
1275                }
1276                var question = questions.eq(z).clone(true, true);
1277                var questionId = question.attr('data-question-id');
1278                var question_original_html = questions.eq(z).find('.ays_quiz_question');
1279
1280                var ays_quiz_question_html    = questions.eq(z).find('.ays_quiz_question');
1281                var question_explanation_html = questions.eq(z).find('.ays_questtion_explanation');
1282                var wrong_answer_text_html    = questions.eq(z).find('.wrong_answer_text');
1283                var right_answer_text_html    = questions.eq(z).find('.right_answer_text');
1284                var note_message_box_html     = questions.eq(z).find('.ays-quiz-question-note-message-box');
1285
1286                var question_parts_arr = new Array(
1287                    note_message_box_html,
1288                    question_explanation_html,
1289                    wrong_answer_text_html,
1290                    right_answer_text_html,
1291                );
1292
1293                question.find('.ays_quiz_question').remove();
1294                question.find('.ays-abs-fs').prepend( questions.eq(z).find('.ays_quiz_question') );
1295
1296                question.find('.ays_questtion_explanation').remove();
1297                question.find('.ays-abs-fs').append( questions.eq(z).find('.ays_questtion_explanation') );
1298
1299                question.find('.wrong_answer_text').remove();
1300                question.find('.ays-abs-fs').append( questions.eq(z).find('.wrong_answer_text') );
1301
1302                question.find('.right_answer_text').remove();
1303                question.find('.ays-abs-fs').append( questions.eq(z).find('.right_answer_text') );
1304
1305                question.find('input[type="button"]').remove();
1306                question.find('input[type="submit"]').remove();
1307                question.find('.ays_arrow').remove();
1308
1309                question.find('.ays-quiz-category-description-box').addClass('ays_display_none');
1310
1311                question.addClass('ays_question_result');
1312                var checked_inputs = question.find('input:checked');
1313                var text_answer = question.find('textarea.ays-text-input');
1314                var number_answer = question.find('input[type="number"].ays-text-input');
1315                var short_text_answer = question.find('input[type="text"].ays-text-input');
1316                var date_answer = question.find('input[type="date"].ays-text-input');
1317                var selected_options = question.find('select');
1318                var answerIsRight = false;
1319
1320                var fieldset_html = "<fieldset class='ays_fieldset'>" + "<legend>" + quizLangObj.notAnsweredText + "</legend>" + "</fieldset>";
1321                var question_html = question.find('.ays-abs-fs > *:not(.ays_quiz_question)').clone(true, true);
1322                
1323                if(showOnlyWrongAnswer === false){
1324                    question.find('input[name="ays_answer_correct[]"][value="1"]').parent().find('label').addClass('correct answered');
1325                    question.find('input[name="ays_answer_correct[]"][value="1"]').parents('div.ays-field').addClass('correct_div');
1326                }
1327
1328                if(checked_inputs.length === 0){
1329                    var emptyAnswer = false;
1330                    if(question.find('input[type="radio"]').length !== 0){
1331                        emptyAnswer = true;
1332                    }
1333                    if(question.find('input[type="checkbox"]').length !== 0){
1334                        emptyAnswer = true;
1335                    }
1336                    if(emptyAnswer){
1337
1338                        var q_answer_text_html = question.find('.ays-abs-fs .ays-quiz-answers');
1339                        question.find('.ays-abs-fs').html(fieldset_html);
1340                        question.find('.ays-abs-fs .ays_fieldset').append(ays_quiz_question_html);
1341                        question.find('.ays-abs-fs .ays_fieldset').append(q_answer_text_html );
1342
1343                        for (var i = 0; i < question_parts_arr.length; i++) {
1344                            question.find('.ays-abs-fs .ays_fieldset').append( question_parts_arr[i] );
1345                        }
1346
1347                        question.find('.ays-abs-fs').css({
1348                            'padding': '7px',
1349                            'width': '100%'
1350                        });
1351                    }
1352                }
1353
1354                var aysAudio = $(document).find('.ays_question_result audio');
1355                if(aysAudio.length > 0){
1356                    aysAudio.each(function(e, el){
1357                        el.pause();
1358                    });
1359                }
1360
1361                selected_options.each(function(element, item){
1362                    var selectOptions = $(item).children("option[data-chisht]");
1363                    var selectedOption = $(item).children("option[data-chisht]:selected");
1364                    var answerClass, answerDivClass, attrChecked, answerClassForSelected, answerClass_tpel, answerViewClass, attrCheckedStyle = "", attrCheckedStyle2;
1365                    var prefixIcon = '', attrCheckedStyle3 = '', attrCheckedStyle4;
1366                    var correctAnswersDiv = '', rectAnswerBefore = "";
1367                    answerViewClass = form.parents('.ays-quiz-container').find('.answer_view_class').val();
1368                    answerViewClass = "ays_"+form.find('.answer_view_class').val()+"_view_item";
1369                    for(var j = 0; j < selectOptions.length; j++){
1370                        if($(selectOptions[j]).attr("value") == '' || $(selectOptions[j]).attr("value") == undefined || $(selectOptions[j]).attr("value") == null){
1371                            continue;
1372                        }
1373                        if($(selectOptions[j]).prop('selected') == true){
1374                            if(parseInt($(selectOptions[j]).data("chisht")) === 1){
1375                                answerClassForSelected = " correct answered ";
1376                                answerDivClass = "correct_div checked_answer_div";
1377                                attrChecked = "checked='checked'";
1378                                answerIsRight = true;
1379                            }else{
1380                                answerClassForSelected = " wrong answered ";
1381                                attrChecked = "checked='checked'";
1382                                answerDivClass = " checked_answer_div ";
1383                            }
1384                        }else{
1385                            if(showOnlyWrongAnswer === false){
1386                                if(parseInt($(selectOptions[j]).data("chisht")) === 1){
1387                                    answerClassForSelected = " correct answered ";
1388                                    answerDivClass = "correct_div checked_answer_div";
1389                                    attrChecked = "";
1390                                }else{
1391                                    answerClassForSelected = "";
1392                                    attrChecked = "";
1393                                    answerDivClass = "";
1394                                }
1395                            }else{
1396                                answerClassForSelected = "";
1397                                attrChecked = "";
1398                                answerDivClass = "";
1399                            }
1400                        }
1401                        attrCheckedStyle2 = "style='padding:0 !important;'";
1402                        if(form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
1403                           form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
1404                            if($(selectOptions[j]).prop('selected') == true){
1405                                if(parseInt($(selectOptions[j]).data("chisht")) === 1){
1406                                    prefixIcon = '<i class="ays_fa answer-icon ays_fa_check_square_o"></i>';
1407                                    attrCheckedStyle3 = "";
1408                                }else{                                                        
1409                                    prefixIcon = '<i class="ays_fa answer-icon ays_fa_check_square_o"></i>';
1410                                    attrCheckedStyle3 = "background-color: rgba(243,134,129,0.8);";
1411                                }
1412                            }else{
1413                                if(showOnlyWrongAnswer === false){
1414                                    if(parseInt($(selectOptions[j]).data("chisht")) === 1){
1415                                        prefixIcon = '<i class="ays_fa answer-icon ays_fa_square_o"></i>';
1416                                        attrCheckedStyle3 = "";
1417                                    }else{
1418                                        prefixIcon = '<i class="ays_fa answer-icon ays_fa_square_o"></i>';
1419                                        attrCheckedStyle3 = "";
1420                                    }
1421                                }else{
1422                                    prefixIcon = '<i class="ays_fa answer-icon ays_fa_square_o"></i>';
1423                                    attrCheckedStyle3 = "";
1424                                }
1425                            }
1426                                attrCheckedStyle = "style='display:block!important;"+attrCheckedStyle3+"'";
1427                                attrCheckedStyle2 = "";
1428                                answerViewClass = "";
1429                           }
1430                        if(form.parents('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') ||
1431                           form.parents('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){
1432                            if($(selectOptions[j]).prop('selected') == true){
1433                                if(parseInt($(selectOptions[j]).data("chisht")) === 1){
1434                                    answerDivClass = "correct_div checked_answer_div";
1435                                    attrCheckedStyle = "style='padding: 0!important;'";
1436                                }else{
1437                                    answerDivClass = "wrong_div checked_answer_div";
1438                                    attrCheckedStyle = "style='padding: 0!important;'";
1439                                }
1440                            }else{
1441                                if(showOnlyWrongAnswer === false){
1442                                    if(parseInt($(selectOptions[j]).data("chisht")) === 1){
1443                                        answerDivClass = "correct_div checked_answer_div";
1444                                    }else{
1445                                        answerDivClass = "";
1446                                    }
1447                                }else{
1448                                    answerDivClass = "";
1449                                }
1450                                attrCheckedStyle = "";
1451                            }
1452                        }
1453                        if(form.parents('.ays-quiz-container').hasClass('ays_quiz_rect_dark') ||
1454                           form.parents('.ays-quiz-container').hasClass('ays_quiz_rect_light')){
1455                            if($(selectOptions[j]).prop('selected') == true){
1456                                if(parseInt($(selectOptions[j]).data("chisht")) === 1){
1457                                    answerDivClass = "correct_div checked_answer_div";
1458                                }else{
1459                                    answerDivClass = "wrong_div checked_answer_div";
1460                                }
1461                                rectAnswerBefore = "rect_answer_correct_before";
1462                            }else{
1463                                if(showOnlyWrongAnswer === false){
1464                                    if(parseInt($(selectOptions[j]).data("chisht")) === 1){
1465                                        answerDivClass = "correct_div checked_answer_div";
1466                                    }else{
1467                                        answerDivClass = "";
1468                                    }
1469                                }else{
1470                                    answerDivClass = "";
1471                                }
1472                                rectAnswerBefore = "rect_answer_wrong_before";
1473                            }
1474                        }
1475                        
1476                        correctAnswersDiv += '<div class="ays-field '+answerViewClass+' '+answerDivClass+'" '+attrCheckedStyle+'>' +
1477                                '<input type="radio" value="'+$(selectOptions[j]).attr("value")+'" name="'+$(item).parent().find('.ays-select-field-value').attr('name')+'" disabled="disabled" '+attrChecked+'>' +
1478                                '<label class="'+answerClassForSelected+'" for="ays-answer-'+$(selectOptions[j]).attr("value")+'">'+prefixIcon+aysEscapeHtml($(selectOptions[j]).text())+'</label> ' +
1479                                '<label for="ays-answer-'+$(selectOptions[j]).attr("value")+'" class="'+answerClassForSelected+'"></label>' +
1480                            '</div>';
1481                    }
1482                    $(item).parent().parent().find('.ays-text-right-answer').remove();
1483                    $(item).parent().parent().append(correctAnswersDiv);
1484                    $(item).parent().hide();
1485
1486                    if(selectedOption.length === 0){
1487                        var _parent_item = $(item).parents('.ays-abs-fs');
1488
1489                        _parent_item.html(fieldset_html);
1490                        _parent_item.find('.ays_fieldset').append(ays_quiz_question_html);
1491                        _parent_item.find('.ays_fieldset').append($(item).parents('.ays-quiz-answers'));
1492
1493                        for (var i = 0; i < question_parts_arr.length; i++) {
1494                            _parent_item.find('.ays_fieldset').append( question_parts_arr[i] );
1495                        }
1496
1497                        $(item).parents('.ays-abs-fs').css({
1498                            'padding': '7px'
1499                        });
1500                    }
1501                    $(item).parents('.ays-abs-fs').find('.ays_buttons_div').remove();
1502                    $(item).parent().remove();
1503                });
1504                
1505                text_answer.next().next().remove();
1506                text_answer.css('width', '100%');
1507                text_answer.attr('disabled', 'disabled');
1508                number_answer.next().next().remove();
1509                number_answer.css('width', '100%');
1510                number_answer.attr('disabled', 'disabled');
1511                short_text_answer.next().next().remove();
1512                short_text_answer.css('width', '100%');
1513                short_text_answer.attr('disabled', 'disabled');
1514                date_answer.next().next().remove();
1515                date_answer.css('width', '100%');
1516                date_answer.attr('disabled', 'disabled');
1517                if(text_answer.val() == ''){
1518                    if(showOnlyWrongAnswer === false){
1519                        var rightAnswerText = '<div class="ays-text-right-answer">';
1520                        var thisQuestionAnswer = text_answer.attr('chishtpatasxan');
1521                        if(typeof thisQuestionAnswer != 'undefined'){
1522                            thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
1523                            thisQuestionAnswer = thisQuestionAnswer.split('%%%');
1524                        }else{
1525                            thisQuestionAnswer = [''];
1526                        }
1527                        rightAnswerText += thisQuestionAnswer[0].trim();
1528
1529                        rightAnswerText += '</div>';
1530                        if(text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
1531                            text_answer.parents('.ays-quiz-answers').append(rightAnswerText);
1532                        }
1533                        text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
1534                            'display': 'block'
1535                        });
1536                    }
1537                    text_answer.css('background-color', 'rgba(243,134,129,0.4)');
1538                    text_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
1539
1540                    var _text_answer_parent = text_answer.parents('.ays-abs-fs');
1541
1542                    _text_answer_parent.html(fieldset_html);
1543                    _text_answer_parent.find('.ays_fieldset').append(ays_quiz_question_html);
1544                    _text_answer_parent.find('.ays_fieldset').append(text_answer.parents('.ays-quiz-answers'));
1545
1546                    for (var i = 0; i < question_parts_arr.length; i++) {
1547                        _text_answer_parent.find('.ays_fieldset').append( question_parts_arr[i] );
1548                    }
1549
1550                    text_answer.parents('.ays-abs-fs').css({
1551                        'padding': '7px'
1552                    });
1553                }else{
1554                    if(parseInt(text_answer.next().val()) == 1){
1555                        text_answer.css('background-color', 'rgba(39,174,96,0.5)');
1556                        answerIsRight = true;
1557                    }else{
1558                        text_answer.css('background-color', 'rgba(243,134,129,0.4)');
1559
1560                        if(showOnlyWrongAnswer === false){
1561                            var rightAnswerText = '<div class="ays-text-right-answer">';
1562                            var thisQuestionAnswer = text_answer.attr('chishtpatasxan');
1563                            if(typeof thisQuestionAnswer != 'undefined'){
1564                                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
1565                                thisQuestionAnswer = thisQuestionAnswer.split('%%%');
1566                            }else{
1567                                thisQuestionAnswer = [''];
1568                            }
1569                            rightAnswerText += thisQuestionAnswer[0].trim();
1570
1571                            rightAnswerText += '</div>';
1572                            if(text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
1573                                text_answer.parents('.ays-quiz-answers').append(rightAnswerText);
1574                            }
1575                            text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
1576                                'display': 'block'
1577                            });
1578                            text_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
1579                        }
1580                    }
1581                }
1582                if(number_answer.val() == ''){
1583                    if(showOnlyWrongAnswer === false){
1584                        var rightAnswerText = '<div class="ays-text-right-answer">'+
1585                            number_answer.attr('chishtpatasxan')+
1586                        '</div>';
1587                        if(number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
1588                            number_answer.parents('.ays-quiz-answers').append(rightAnswerText);
1589                        }
1590                        number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
1591                            'display': 'block'
1592                        });
1593                    }
1594                    number_answer.css('background-color', 'rgba(243,134,129,0.8)');
1595                    number_answer.parents('.ays-abs-fs').find('.ays-quiz-number-error-message').addClass('ays_display_none');
1596
1597                    var _number_answer_parent = number_answer.parents('.ays-abs-fs');
1598
1599                    _number_answer_parent.html(fieldset_html);
1600                    _number_answer_parent.find('.ays_fieldset').append(ays_quiz_question_html);
1601                    _number_answer_parent.find('.ays_fieldset').append(number_answer.parents('.ays-quiz-answers'));
1602                    
1603                    for (var i = 0; i < question_parts_arr.length; i++) {
1604                        _number_answer_parent.find('.ays_fieldset').append( question_parts_arr[i] );
1605                    }
1606
1607                    number_answer.parents('.ays-abs-fs').css({
1608                        'padding': '7px'
1609                    });
1610                }else{
1611                    if(parseInt(number_answer.next().val()) == 1){
1612                        number_answer.css('background-color', 'rgba(39,174,96,0.5)');
1613                        answerIsRight = true;
1614                    }else{
1615                        number_answer.css('background-color', 'rgba(243,134,129,0.4)');
1616                        if(showOnlyWrongAnswer === false){
1617                            var rightAnswerText = '<div class="ays-text-right-answer">'+
1618                                number_answer.attr('chishtpatasxan')+
1619                                '</div>';
1620                            if(number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
1621                                number_answer.parents('.ays-quiz-answers').append(rightAnswerText);
1622                            }
1623                            number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
1624                                'display': 'block'
1625                            });
1626                            number_answer.parents('.ays-abs-fs').find('.ays-quiz-number-error-message').addClass('ays_display_none');
1627                        }
1628                    }
1629                }
1630                if(short_text_answer.val() == ''){
1631                    if(showOnlyWrongAnswer === false){
1632                        var rightAnswerText = '<div class="ays-text-right-answer">';
1633                        var thisQuestionAnswer = short_text_answer.attr('chishtpatasxan');
1634                        if(typeof thisQuestionAnswer != 'undefined'){
1635                            thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
1636                            thisQuestionAnswer = thisQuestionAnswer.split('%%%');
1637                        }else{
1638                            thisQuestionAnswer = [''];
1639                        }
1640                        rightAnswerText += thisQuestionAnswer[0].trim();
1641
1642                        rightAnswerText += '</div>';
1643                        if(short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
1644                            short_text_answer.parents('.ays-quiz-answers').append(rightAnswerText);
1645                        }
1646                        short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
1647                            'display': 'block'
1648                        });
1649                    }
1650                    short_text_answer.css('background-color', 'rgba(243,134,129,0.8)');
1651                    short_text_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
1652
1653                    var _short_text_parent = short_text_answer.parents('.ays-abs-fs');
1654
1655                    _short_text_parent.html(fieldset_html);
1656                    _short_text_parent.find('.ays_fieldset').append(ays_quiz_question_html);
1657                    _short_text_parent.find('.ays_fieldset').append(short_text_answer.parents('.ays-quiz-answers'));
1658                    
1659                    for (var i = 0; i < question_parts_arr.length; i++) {
1660                        _short_text_parent.find('.ays_fieldset').append( question_parts_arr[i] );
1661                    }
1662
1663                    short_text_answer.parents('.ays-abs-fs').css({
1664                        'padding': '7px'
1665                    });
1666                }else{
1667                    if(parseInt(short_text_answer.next().val()) == 1){
1668                        short_text_answer.css('background-color', 'rgba(39,174,96,0.5)');
1669                        answerIsRight = true;
1670                    }else{
1671                        short_text_answer.css('background-color', 'rgba(243,134,129,0.4)');
1672                        if(showOnlyWrongAnswer === false){
1673                            var rightAnswerText = '<div class="ays-text-right-answer">';
1674                            var thisQuestionAnswer = short_text_answer.attr('chishtpatasxan');
1675                            if(typeof thisQuestionAnswer != 'undefined'){
1676                                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
1677                                thisQuestionAnswer = thisQuestionAnswer.split('%%%');
1678                            }else{
1679                                thisQuestionAnswer = [''];
1680                            }
1681                            rightAnswerText += thisQuestionAnswer[0].trim();
1682
1683                            rightAnswerText += '</div>';
1684                            if(short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
1685                                short_text_answer.parents('.ays-quiz-answers').append(rightAnswerText);
1686                            }
1687                            short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
1688                                'display': 'block'
1689                            });
1690                            short_text_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
1691                        }
1692                    }
1693                }
1694                if(date_answer.val() == ''){
1695                    if(showOnlyWrongAnswer === false){
1696                        var rightAnswerText = '<div class="ays-text-right-answer">';
1697                        var thisQuestionAnswer = date_answer.attr('chishtpatasxan');
1698
1699                        var correctDate = new Date(thisQuestionAnswer),
1700                            correctDateYear = correctDate.getFullYear(),
1701                            correctDateMonth = (correctDate.getMonth() + 1) < 10 ? "0"+(correctDate.getMonth() + 1) : (correctDate.getMonth() + 1),
1702                            correctDateDay = (correctDate.getDate() < 10) ? "0"+correctDate.getDate() : correctDate.getDate();
1703                        rightAnswerText += [correctDateMonth, correctDateDay, correctDateYear].join('/');
1704
1705                        rightAnswerText += '</div>';
1706                        if(date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
1707                            date_answer.parents('.ays-quiz-answers').append(rightAnswerText);
1708                        }
1709                        date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
1710                            'display': 'block'
1711                        });
1712                    }
1713                    date_answer.css('background-color', 'rgba(243,134,129,0.8)');
1714
1715                    var _date_answer_parent = date_answer.parents('.ays-abs-fs');
1716
1717                    _date_answer_parent.html(fieldset_html);
1718                    _date_answer_parent.find('.ays_fieldset').append(ays_quiz_question_html);
1719                    _date_answer_parent.find('.ays_fieldset').append(date_answer.parents('.ays-quiz-answers'));
1720                    
1721                    for (var i = 0; i < question_parts_arr.length; i++) {
1722                        _date_answer_parent.find('.ays_fieldset').append( question_parts_arr[i] );
1723                    }
1724
1725                    date_answer.parents('.ays-abs-fs').css({
1726                        'padding': '7px'
1727                    });
1728                }else{
1729                    if(parseInt(date_answer.next().val()) == 1){
1730                        date_answer.css('background-color', 'rgba(39,174,96,0.5)');
1731                        answerIsRight = true;
1732                    }else{
1733                        date_answer.css('background-color', 'rgba(243,134,129,0.4)');
1734                        if(showOnlyWrongAnswer === false){
1735                            var rightAnswerText = '<div class="ays-text-right-answer">';
1736                            var thisQuestionAnswer = date_answer.attr('chishtpatasxan');
1737                            var correctDate = new Date(thisQuestionAnswer),
1738                                correctDateYear = correctDate.getFullYear(),
1739                                correctDateMonth = (correctDate.getMonth() + 1) < 10 ? "0"+(correctDate.getMonth() + 1) : (correctDate.getMonth() + 1),
1740                                correctDateDay = (correctDate.getDate() < 10) ? "0"+correctDate.getDate() : correctDate.getDate();
1741                            rightAnswerText += [correctDateMonth, correctDateDay, correctDateYear].join('/');
1742
1743                            rightAnswerText += '</div>';
1744                            if(date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length
1744 == 0){
1745                                date_answer.parents('.ays-quiz-answers').append(rightAnswerText);
1746                            }
1747                            date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
1748                                'display': 'block'
1749                            });
1750                        }
1751                    }
1752                }
1753
1754                if (checked_inputs.length === 1) {
1755                    if(parseInt(checked_inputs.prev().val()) === 1){
1756                        checked_inputs.parent().addClass('checked_answer_div').addClass('correct_div');
1757                        checked_inputs.parent().find('label').addClass('correct answered');
1758                        answerIsRight = true;
1759                        if(form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
1760                           form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
1761                            $(checked_inputs).next().css('background-color', "transparent");
1762                            $(checked_inputs).parent().css('background-color', ' rgba(158,208,100,0.8)');
1763                        }
1764                    }else{
1765                        if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
1766                           $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
1767                            $(checked_inputs).next().css('background-color', "transparent");
1768                            $(checked_inputs).parent().css('background-color', ' rgba(243,134,129,0.8)');
1769                        }
1770                        checked_inputs.parent().addClass('checked_answer_div').addClass('wrong_div');
1771                        checked_inputs.parent().find('label').addClass('wrong wrong_div answered');
1772                    }
1773
1774                    if($(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') ||
1775                       $(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){
1776                        $(this).next().css('padding', "0 10px 0 10px");
1777                    }
1778                    $(checked_inputs).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', true);
1779                }else if(checked_inputs.length > 1){
1780                    var checked_right = 0;
1781                    checked_inputs.map(function() {
1782                        if(parseInt($(this).prev().val()) === 1){
1783                            $(this).parent().addClass('checked_answer_div').addClass('correct_div');
1784                            $(this).parent().find('label').addClass('correct answered');
1785                            if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
1786                               $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
1787                                $(this).next().css('background-color', "transparent");
1788                                $(this).parent().css('background-color', ' rgba(158,208,100,0.8)');
1789                            }
1790                        }else{ 
1791                            $(this).parent().addClass('checked_answer_div').addClass('wrong_div');
1792                            $(this).parent().find('label').addClass('wrong wrong_div answered');
1793                            checked_right++;
1794                            if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
1795                               $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
1796                                $(this).next().css('background-color', "transparent");
1797                                $(this).parent().css('background-color', ' rgba(243,134,129,0.8)');
1798                            }
1799                        }
1800                        if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
1801                           $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
1802                        }
1803
1804                        if($(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') ||
1805                           $(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){
1806                        }
1807                        $(this).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', true);
1808                    });
1809                    if(checked_right == 0){
1810                        answerIsRight = true;
1811                    }
1812                }
1813
1814                myOptions.hide_correct_answers = (myOptions.hide_correct_answers) ? myOptions.hide_correct_answers : 'off';
1815                var hideRightAnswers =(myOptions.hide_correct_answers && myOptions.hide_correct_answers == 'on') ? true : false;
1816                if (hideRightAnswers) {
1817                    question.find('.ays-text-right-answer').addClass("ays_quiz_display_none_important");
1818                    var aysFieldsets = question.find('fieldset.ays_fieldset');
1819                    if (aysFieldsets.length > 0) {
1820                        var aysFieldsetsField = aysFieldsets.find('.ays-field');
1821                        if (aysFieldsetsField.hasClass('correct_div')) {
1822                            aysFieldsetsField.removeClass('correct_div');
1823                        }
1824                        if (aysFieldsetsField.hasClass('checked_answer_div')) {
1825                            aysFieldsetsField.removeClass('checked_answer_div');
1826                        }
1827                        if (aysFieldsetsField.find('label').hasClass('correct')) {
1828                            aysFieldsetsField.find('label').removeClass('correct');
1829                        }
1830                    }
1831                    var answers_box = question.find('.ays-quiz-answers');
1832                    if (answers_box.length > 0) {
1833                        answers_box.each(function () {
1834                           var userWrongAnswered = $(this).find('.ays-field');
1835                           var userWrongAnsweredLabel = userWrongAnswered.find('label');
1836                           var questionTypeCheckbox = userWrongAnswered.find('input[type="checkbox"]');
1837                           if (userWrongAnsweredLabel.hasClass('wrong') || questionTypeCheckbox.length > 0) {
1838                                if (userWrongAnsweredLabel.hasClass('correct') && userWrongAnsweredLabel.hasClass('answered')) {
1839                                    var eachAnswers = userWrongAnswered.find('input[name^="ays_questions"]');
1840                                    if (eachAnswers.length > 0) {
1841                                        eachAnswers.each(function () {
1842                                            var parentBox = $(this).parents('.ays-field');
1843                                            if (! $(this).prop("checked")) {
1844                                                $(this).next().removeClass('correct');
1845                                                if (parentBox.hasClass('correct_div')) {
1846                                                    parentBox.removeClass('correct_div');
1847                                                }
1848                                                if (parentBox.hasClass('checked_answer_div')) {
1849                                                    parentBox.removeClass('checked_answer_div');
1850                                                }
1851                                                if (! parentBox.hasClass('.checked_answer_div') ) {
1852                                                    parentBox.find('input~label.answered.correct').addClass('ays_quiz_hide_correct_answer');
1853                                                }
1854                                            }
1855                                        });
1856                                    }
1857                                }
1858                           }
1859                        });
1860                    }
1861                }
1862
1863                answerIsRightArr[ 'questionId_' + questionId ] = answerIsRight;
1864
1865                if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_results_page' || myOptions.answers_rw_texts == 'on_both')){
1866                    if(answerIsRight){
1867                        question.find('.right_answer_text').css("display", "block");
1868                    }else{
1869                        question.find('.wrong_answer_text').css("display", "block");
1870                    }
1871                }else{
1872                    question.find('.right_answer_text').css("display", "none");
1873                    question.find('.wrong_answer_text').css("display", "none");
1874                }
1875                // question.find('.ays_questtion_explanation').css("display", "block");
1876                var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page";
1877                if(showExplanationOn == 'on_results_page' || showExplanationOn == 'on_both'){
1878                    if(! question.hasClass('not_influence_to_score')){
1879                        question.find('.ays_questtion_explanation').css("display", "block");
1880                    }
1881                }else{
1882                    question.find('.ays_questtion_explanation').css("display", "none");
1883                }
1884                question.find('.ays_user_explanation').css("display", "none");
1885                question.css("pointer-events", "auto");
1886                question.find('.ays-quiz-answers').css("pointer-events", "none");
1887                formResults.append(question);
1888            }
1889
1890            myOptions.quiz_show_wrong_answers_first = ! myOptions.quiz_show_wrong_answers_first ? 'off' : myOptions.quiz_show_wrong_answers_first;
1891            var quiz_show_wrong_answers_first = (myOptions.quiz_show_wrong_answers_first && myOptions.quiz_show_wrong_answers_first == 'on') ? true : false;
1892
1893            myOptions.quiz_show_only_wrong_answers = ! myOptions.quiz_show_only_wrong_answers ? 'off' : myOptions.quiz_show_only_wrong_answers;
1894            var quiz_show_only_wrong_answers = (myOptions.quiz_show_only_wrong_answers && myOptions.quiz_show_only_wrong_answers == 'on') ? true : false;
1895
1896            if ( quiz_show_wrong_answers_first || quiz_show_only_wrong_answers) {
1897                var UserAnswered_true_arr  = new Array();
1898                var UserAnswered_false_arr = new Array();
1899                for (var question_ID in answerIsRightArr) {
1900
1901                    var question_ID_arr = question_ID.split("_");
1902                    var questionDataID  = question_ID_arr[1];
1903
1904                    var UserAnswered_true_or_false = answerIsRightArr[question_ID];
1905                    var questionHTML = form.find('.ays_quiz_results div.ays_question_result[data-question-id="'+ questionDataID +'"]').clone();
1906
1907                    if ( UserAnswered_true_or_false ) {
1908                        UserAnswered_true_arr.push( questionHTML );
1909                    } else {
1910                        UserAnswered_false_arr.push( questionHTML );
1911                    }
1912                }
1913
1914                if ( quiz_show_only_wrong_answers ) {
1915                    UserAnswered_true_arr = new Array();
1916                }
1917
1918                var allQuestionHTML = UserAnswered_false_arr.concat( UserAnswered_true_arr );
1919
1920                formResults.html('');
1921
1922                if ( quiz_enable_results_toggle ) {
1923                    formResults.append(resultToggleHTML);
1924                }
1925
1926                for (var ii = 0; ii < allQuestionHTML.length; ii++) {
1927                    formResults.append( allQuestionHTML[ii] );
1928                }
1929            }
1930        }
1931        
1932        var showResults = true;
1933        if ( (myOptions.enable_paypal && myOptions.enable_paypal === 'on') || 
1934            ( myOptions.enable_stripe && myOptions.enable_stripe === 'on' ) ) {
1935            if (myOptions.payment_type && myOptions.payment_type === 'postpay') {
1936                showResults = false;
1937            }else{
1938                showResults = true;
1939            }
1940        }
1941
1942        if( showResults === true ){
1943            form.find('.ays_quiz_results').slideDown(1000);
1944        }
1945
1946        form.find('.ays_quiz_rete').fadeIn(250);
1947        form.find('.for_quiz_rate').rating({
1948            onRate: function(res){
1949                $(this).rating('disable');
1950                $(this).parent().find('.for_quiz_rate_reason').slideDown(500);
1951                $(this).parents('.ays_quiz_rete').attr('data-rate_score', res);
1952            }
1953        });
1954        var aysQuizLoader = form.find('div[data-role="loader"]');
1955        aysQuizLoader.addClass('ays-loader');
1956        aysQuizLoader.removeClass(aysQuizLoader.data('class'));
1957        aysQuizLoader.find('.ays-loader-content').css('display','none');
1958
1959        var openResultsPage = true;
1960        window.aysResultsForQuizStored = false;
1961        if ( (myOptions.enable_paypal && myOptions.enable_paypal === 'on') || 
1962            (myOptions.enable_stripe && myOptions.enable_stripe === 'on') ) {
1963            if (myOptions.payment_type && myOptions.payment_type === 'prepay') {
1964                openResultsPage = true;
1965            }else{
1966                openResultsPage = false;
1967                if( !window.aysResultsForQuizStored ) {
1968                    window.aysResultsForQuiz = form.find('.ays_quiz_results_page').html();
1969                    window.aysResultsForQuizStored = true;
1970                    form.find('.ays_quiz_results_page').html('');
1971                }
1972            }
1973        }
1974
1975        if( openResultsPage === true ){
1976            form.find('.ays_quiz_results_page').css({'display':'block'});
1977        }
1978
1979        form.find('.ays_paypal_wrap_div, .ays_stripe_wrap_div').css({'display':'block'});
1980        form.find('.ays_paypal_wrap_div, .ays_stripe_wrap_div').attr('data-result', response.result_id);
1981
1982        form.css({'display':'block'});
1983        form.on('click', '.ays_quiz_rete .for_quiz_rate_reason .action-button', function(){
1984
1985            var _this = $(this);
1986            var _parent = _this.parents('.for_quiz_rate_reason');
1987            
1988            if(myOptions.quiz_make_review_required == 'on' && myOptions.quiz_make_review_required == 'on'){
1989
1990                var _el = _parent.find('.quiz_rate_reason[data-required="true"]');
1991
1992                if ( ! _this.hasClass('start_button') ) {
1993                    if ( _el.length !== 0 ) {
1994                        var empty_inputs = 0;
1995
1996                        if (_el.val().trim() === '' &&
1997                            _el.attr('type') !== 'hidden') {
1998                            _el.addClass('ays_red_border');
1999                            _el.addClass('ays_animated_x5ms');
2000                            _el.addClass('shake');
2001                            empty_inputs++;
2002                        }
2003
2004                        var errorFields = _parent.find('.ays_red_border');
2005                        if ( empty_inputs !== 0 ) {
2006                            setTimeout(function(){
2007                                errorFields.each(function(){
2008                                    $(this).removeClass('shake');
2009                                });
2010                            }, 500);
2011                            return false;
2012                        }
2013                    }
2014                }
2015            }
2016
2017            $(this).parents('.for_quiz_rate_reason').find('.quiz_rate_reason').attr('disabled', 'disabled');
2018            var data = {};
2019            var quizId = form.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
2020            var quizCusrrentPageLink = form.parents('.ays-quiz-container').find('input[name="ays_quiz_curent_page_link"]').val();
2021            data.action = 'ays_rate_the_quiz';
2022            data.rate_reason = $(this).parents('.for_quiz_rate_reason').find('.quiz_rate_reason').val();
2023            data.rate_score = $(this).parents('.ays_quiz_rete').data('rate_score');
2024            data.rate_date = GetFullDateTime();
2025            data.quiz_id = quizId;
2026            data.last_result_id = last_result_id;
2027            data.quiz_make_responses_anonymous = quiz_make_responses_anonymous;
2028            data.quiz_current_page_link = quizCusrrentPageLink;
2029            form.find('.for_quiz_rate_reason').slideUp(800);
2030            var showAvgRate = false;
2031            myOptions.show_rate_after_rate = (myOptions.show_rate_after_rate) ? myOptions.show_rate_after_rate : 'on';
2032            if(myOptions.show_rate_after_rate && myOptions.show_rate_after_rate == 'on'){
2033                showAvgRate = true;
2034            }
2035            if(showAvgRate){
2036                $(this).parents('.ays_quiz_rete').find('.lds-spinner-none').addClass('lds-spinner').removeClass('lds-spinner-none');
2037            }
2038            if(myOptions.enable_quiz_rate == 'on' && myOptions.enable_rate_comments == 'on'){
2039                $(this).parents('.ays_quiz_rete').find('.lds-spinner2-none').addClass('lds-spinner2').removeClass('lds-spinner2-none');
2040            }
2041            $.ajax({
2042                url: quiz_maker_ajax_public.ajax_url,
2043                method: 'post',
2044                dataType: 'json',
2045                data: data,
2046                success: function(response){
2047                    if(response.status === true){
2048                        setTimeout(function(){
2049                            form.find('.ays_quiz_rete').find('.for_quiz_rate').attr('data-rating', response.score);
2050                            form.find('.ays_quiz_rete').find('.for_quiz_rate').rating({
2051                                initialRating: response.score
2052                            });
2053                            form.find('.ays_quiz_rete').find('.for_quiz_rate').rating('disable');
2054                            if(showAvgRate){
2055                                form.find('.lds-spinner').addClass('lds-spinner-none').removeClass('lds-spinner');
2056                                form.find('.for_quiz_rate_reason').html('<p>'+response.rates_count + ' ' + quizLangObj.votes + ', ' + response.avg_score + ' ' + quizLangObj.avg + ' </p>');
2057                                form.find('.for_quiz_rate_reason').fadeIn(250);
2058                            }
2059                            if(myOptions.enable_quiz_rate == 'on' && myOptions.enable_rate_comments == 'on'){
2060                                var data = {};
2061                                data.action = 'ays_get_rate_last_reviews';
2062                                data.quiz_id = response.quiz_id;
2063                                $.ajax({
2064                                    url: quiz_maker_ajax_public.ajax_url,
2065                                    method: 'post',
2066                                    data: data,
2067                                    success: function(response){
2068                                        var response_arr = JSON.parse(response);
2069                                        var responseHTML = (response_arr.quiz_rate_html && response_arr.quiz_rate_html != '') ? response_arr.quiz_rate_html : '';
2070
2071                                        form.find('.quiz_rate_reasons_body').html(responseHTML);
2072                                        form.find('.lds-spinner2').addClass('lds-spinner2-none').removeClass('lds-spinner2');
2073                                        form.find('.quiz_rate_reasons_container').slideDown(500);
2074                                        form.find('.ays-quiz-rate-link-box .ays-quiz-rate-link').slide
2074Up(500);
2075                                        form.on('click', 'button.ays_load_more_review', function(e){
2076                                            form.find('.quiz_rate_load_more [data-role="loader"]').addClass(form.find('.quiz_rate_load_more .ays-loader').data('class')).removeClass('ays-loader');
2077                                            var startFrom = parseInt($(e.target).attr('startfrom'));
2078                                            var zuyga = parseInt($(e.target).attr('zuyga'));
2079                                            $.ajax({
2080                                                url: quiz_maker_ajax_public.ajax_url,
2081                                                method: 'post',
2082                                                data:{
2083                                                    action: 'ays_load_more_reviews',
2084                                                    quiz_id: quizId,
2085                                                    start_from: startFrom,
2086                                                    zuyga: zuyga
2087                                                },
2088                                                success: function(resp){
2089                                                    if(zuyga == 0){
2090                                                        zuyga = 1;
2091                                                    }else{
2092                                                        zuyga = 0;
2093                                                    }
2094                                                    
2095                                                    form.find('.quiz_rate_load_more [data-role="loader"]').addClass('ays-loader').removeClass(form.find('.quiz_rate_load_more .ays-loader').data('class'));
2096                                                    form.find('.quiz_rate_reasons_container').append(resp);
2097                                                    form.find('.quiz_rate_more_review:last-of-type').slideDown(500);
2098                                                    $(e.target).attr('startfrom', startFrom + 5 );
2099                                                    $(e.target).attr('zuyga', zuyga);
2100                                                    if(form.find('.quiz_rate_reasons_container p.ays_no_more').length > 0){
2101                                                        $(e.target).remove();
2102                                                    }
2103                                                }
2104                                            });
2105                                        });
2106                                    },
2107                                    error: function(jqXHR, textStatus, errorThrown) {}
2108                                });
2109                            }
2110                        },1000);
2111                    }
2112                }
2113            });
2114        });
2115    }
2116
2117    function redirect_timer(timer, args) {
2118        if( typeof args == 'undefined' ){
2119           args = {};
2120        }
2121
2122        var tabTitle = document.title;
2123
2124        var countDownDate = new Date().getTime() + (timer * 1000);
2125
2126        var x = setInterval(function () {
2127            var now = new Date().getTime();
2128            var distance = countDownDate - Math.ceil(now/1000)*1000;
2129            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
2130            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
2131            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
2132            var timeForShow = "";
2133            if(hours <= 0){
2134                hours = null;
2135            }else if (hours < 10) {
2136                hours = '0' + hours;
2137            }
2138            if (minutes < 10) {
2139                minutes = '0' + minutes;
2140            }
2141            if (seconds < 10) {
2142                seconds = '0' + seconds;
2143            }
2144            timeForShow =  ((hours==null)? "" : (hours + ":")) + minutes + ":" + seconds;
2145            if(distance <=1000){
2146                timeForShow = ((hours==null) ? "" : "00:") + "00:00";
2147                $(document).find('.ays-quiz-container').find('div.ays-quiz-redirection-timer').html(timeForShow);
2148                document.title = timeForShow + " - " + tabTitle;
2149            }else{
2150                 $(document).find('.ays-quiz-container').find('div.ays-quiz-redirection-timer').html(timeForShow);
2151                document.title = timeForShow + " - " + tabTitle;
2152            }
2153            $(document).find('.ays-quiz-container').find('div.ays-quiz-redirection-timer').slideDown(500);
2154            var ays_interval_element_redirect_url = args.redirectUrl;
2155
2156            if (distance <= 1000) {
2157                clearInterval(x);
2158                window.location = ays_interval_element_redirect_url;
2159            }
2160        }, 1000);
2161    }
2162    
2163    function redirectAction(redirectUrl, redirectDelay, blockElement, redirectAfter, form, myOptions, redirectMessageFlag){
2164        var timer = parseInt(redirectDelay);
2165        if(timer === NaN){
2166            timer = 0;
2167        }
2168
2169        if( timer == 0 ){
2170            window.location = redirectUrl;
2171            return false;
2172        }
2173
2174        if ( redirectMessageFlag ) {
2175            var quizId = form.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
2176            // Message before redirect timer
2177            var quiz_message_before_redirect_timer = (myOptions.quiz_message_before_redirect_timer && myOptions.quiz_message_before_redirect_timer != "") ? ( myOptions.quiz_message_before_redirect_timer ) : '';
2178
2179            if ( quiz_message_before_redirect_timer != '' ) {
2180                quiz_message_before_redirect_timer = quiz_message_before_redirect_timer.replace(/(["'])/g, "\\$1") + " ";
2181
2182                $(document).find('html > head').append('<style> #ays-quiz-container-'+ quizId +' div.ays-quiz-redirection-timer:before{content: "'+ quiz_message_before_redirect_timer +'"; }</style>');
2183            }
2184        }
2185
2186        var tabTitle = document.title;
2187        var timerText = $('<section class="ays_quiz_redirection_timer_container">'+
2188            '<div class="ays-quiz-redirection-timer">'+
2189            quizLangObj.redirectAfter + ' ' + redirectAfter +
2190            '</div><hr></section>');
2191        form.parents('.ays-quiz-container').prepend(timerText);
2192        blockElement.find('.ays_quiz_redirection_timer_container').css({
2193            height: 'auto'
2194        });
2195        setTimeout(function(){
2196            if (timer !== NaN) {
2197                timer += 2;
2198                if (timer !== undefined) {
2199                    blockElement.find('div.ays-quiz-redirection-timer').slideUp(500);
2200                    redirect_timer( timer,  {
2201                        redirectUrl: redirectUrl
2202                    });
2203                }
2204            }
2205        }, 2000);
2206
2207        return true;
2208    }
2209
2210    function aysQuizSetCustomEvent() {
2211        if ( typeof window.CustomEvent === "function" ) return false; //If not IE
2212    
2213        function CustomEvent ( event, params ) {
2214            params = params || { bubbles: false, cancelable: false, detail: undefined };
2215            var evt = document.createEvent( 'CustomEvent' );
2216            evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
2217            return evt;
2218        }
2219    
2220        CustomEvent.prototype = window.Event.prototype;
2221    
2222        window.CustomEvent = CustomEvent;
2223    }
2224
2225
2226})(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.