PageSourceSearch

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

js braintests.net collected 2026-09-24 15:07:31 UTC 189,451 bytes, 3,412 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
24        window.aysMatchingAnsweredOptionCount = null;
25
26        window.aysQuizParentWindowLink = null;
27        if (window.location != window.parent.location) {
28            window.parent.postMessage("getParentUrl", "*");
29            window.addEventListener("message", receiveMessage, false);
30        }
31
32        function receiveMessage(event) {
33            if (typeof event.data === "string") {
34                window.aysQuizParentWindowLink = event.data;
35            }
36        }
37
38        if(!$.fn.goTo){
39            $.fn.goTo = function(myOptions) {
40                var QuizAnimationTop = (myOptions.quiz_animation_top && myOptions.quiz_animation_top != 0) ? parseInt(myOptions.quiz_animation_top) : 100;
41
42                myOptions.quiz_enable_animation_top = myOptions.quiz_enable_animation_top ? myOptions.quiz_enable_animation_top : 'on';
43                var EnableQuizAnimationTop = ( myOptions.quiz_enable_animation_top && myOptions.quiz_enable_animation_top == 'on' ) ? true : false;
44                if( EnableQuizAnimationTop ){
45                    $('html, body').animate({
46                        scrollTop: $(this).offset().top - QuizAnimationTop + 'px'
47                    }, 'slow');
48                }
49                return this; // for chaining...
50            }
51        }
52        // for details
53        $.fn.aysModal = function(action){
54            var $this = $(this);
55            switch(action){
56                case 'hide':
57                    $(this).find('.ays-modal-content').css('animation-name', 'zoomOut');
58                    setTimeout(function(){
59                        $(document.body).removeClass('modal-open');
60                        $(document).find('.ays-modal-backdrop').remove();
61                        $this.hide();
62                    }, 250);
63                    break;
64                case 'show':
65                default:
66                    $this.show();
67                    $(this).find('.ays-modal-content').css('animation-name', 'zoomIn');
68                    $(document).find('.modal-backdrop').remove();
69                    $(document.body).append('<div class="ays-modal-backdrop"></div>');
70                    $(document.body).addClass('modal-open');
71                    break;
72            }
73        }
74
75        if (!String.prototype.trim) {
76            (function() {
77                String.prototype.trim = function() {
78                    return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
79                };
80            })();
81        }
82        $(document).find(".ays-quiz-container .information_form").each(function(e){
83            var $this = $(this);
84            var cont = $(document).find(".ays-quiz-container");
85            var thisCont = $this.parents('.ays-quiz-container');
86            var quizId = thisCont.find('input[name="ays_quiz_id"]').val();
87            var myOptions = JSON.parse(window.atob(window.aysQuizOptions[quizId]));
88            if(myOptions.autofill_user_data && myOptions.autofill_user_data == "on"){
89                var userData = {};
90                userData.action = 'ays_get_user_information';
91                $.ajax({
92                    url: quiz_maker_ajax_public.ajax_url,
93                    method: 'post',
94                    dataType: 'json',
95                    crossDomain: true,
96                    data: userData,
97                    success: function (response) {
98                        if(response !== null){
99                            $this.find("input[name='ays_user_name']").val(response.data.display_name);
100                            $this.find("input[name='ays_user_email']").val(response.data.user_email);
101                        }
102                    }
103                });
104            }
105        });
106
107        $(document).on('click', '.ays-quiz-rate-link-box .ays-quiz-rate-link', function (e) {
108            e.preventDefault();
109            var _this  = $(this);
110            var parent = _this.parents('.ays-quiz-container');
111            var quizId = parent.find('input[name="ays_quiz_id"]').val();
112            var form   = parent.find('form.ays-quiz-form');
113
114            var action = 'ays_get_rate_last_reviews';
115            $.ajax({
116                url: quiz_maker_ajax_public.ajax_url,
117                method: 'post',
118                dataType: 'json',
119                crossDomain: true,
120                data: {
121                    quiz_id: quizId,
122                    action: action
123                },
124                success: function(response){
125                    if(response.status === true){
126                        form.find('.quiz_rate_reasons_body').html(response.quiz_rate_html);
127                        form.find('.lds-spinner2').addClass('lds-spinner2-none').removeClass('lds-spinner2');
128                        form.find('.quiz_rate_reasons_container').slideDown(500);
129
130                        _this.slideUp(500);
131
132                        form.on('click', 'button.ays_load_more_review', function(e){
133                            form.find('.quiz_rate_load_more [data-role="loader"]').addClass(form.find('.quiz_rate_load_more .ays-loader').data('class')).removeClass('ays-loader');
134                            var startFrom = parseInt($(e.target).attr('startfrom'));
135                            var zuyga = parseInt($(e.target).attr('zuyga'));
136                            $.ajax({
137                                url: quiz_maker_ajax_public.ajax_url,
138                                method: 'post',
139                                crossDomain: true,
140                                data:{
141                                    action: 'ays_load_more_reviews',
142                                    quiz_id: quizId,
143                                    start_from: startFrom,
144                                    zuyga: zuyga
145                                },
146                                success: function(resp){
147                                    if(zuyga == 0){
148                                        zuyga = 1;
149                                    }else{
150                                        zuyga = 0;
151                                    }
152
153                                    form.find('.quiz_rate_load_more [data-role="loader"]').addClass('ays-loader').removeClass(form.find('.quiz_rate_load_more .ays-loader').data('class'));
154                                    form.find('.quiz_rate_reasons_container').append(resp);
155                                    form.find('.quiz_rate_more_review:last-of-type').slideDown(500);
156                                    $(e.target).attr('startfrom', startFrom + 5 );
157                                    $(e.target).attr('zuyga', zuyga);
158                                    if(form.find('.quiz_rate_reasons_container p.ays_no_more').length > 0){
159                                        $(e.target).remove();
160                                    }
161                                }
162                            });
163                        });
164                    } else {
165                        swal.fire({
166                            type: 'info',
167                            html: "<h2>"+ quizLangObj.loadResource +"</h2><br><h6>"+ quizLangObj.somethingWentWrong +"</h6>"
168                        });
169                    }
170                },
171                error: function(){
172                    swal.fire({
173                        type: 'info',
174                        html: "<h2>"+ quizLangObj.loadResource +"</h2><br><h6>"+ quizLangObj.somethingWentWrong +"</h6>"
175                    });
176                }
177            });
178        });
179
180        $(document).find('input.ays_finish').on('click', function (e) {
181            e.preventDefault();
182
183            var _this = $(this);
184            ays_quiz_container_id = $(this).parents(".ays-quiz-container").attr("id");
185            ays_quiz_container = $('#'+ays_quiz_container_id);
186
187            var quizId = ays_quiz_container.find('input[name="ays_quiz_id"]').val();
188            var myOptions = JSON.parse(window.atob(window.aysQuizOptions[quizId]));
189            var quizOptionsName = 'quizOptions_'+quizId;
190            var myQuizOptions = [];
191            var checkboxMinCountAndNavigationFlag = false;
192            
193            if(typeof window[quizOptionsName] !== 'undefined'){
194                for(var i in window[quizOptionsName]){
195                    if(window[quizOptionsName].hasOwnProperty(i)){
196                        myQuizOptions[i] = (JSON.parse(window.atob(window[quizOptionsName][i])));
197                    }
198                }
199            }
200
201            var form = ays_quiz_container.find('form.ays-quiz-form');
202
203            myOptions.enable_recaptcha = ( myOptions.enable_recaptcha ) ? myOptions.enable_recaptcha : 'off';
204            var quizRecaptcha = myOptions.enable_recaptcha && myOptions.enable_recaptcha == "on" ? true : false;
205
206            var formCaptchaValidation = null;
207            if( quizRecaptcha ){
208                if( form.attr('data-recaptcha-validate') ){
209                    formCaptchaValidation = form.attr('data-recaptcha-validate') == 'true' ? true : false;
210                }
211            }
212
213            if( quizRecaptcha && formCaptchaValidation === null){
214                var cEvent = new CustomEvent('afterQuizSubmission', {
215                    detail: {
216                        _this: _this,
217                        thisButton: $( e.target )
218                    }
219                });
220                form.get(0).dispatchEvent(cEvent);
221            }
222
223            if( quizRecaptcha === false ){
224                formCaptchaValidation = true;
225            }
226
227            if ( formCaptchaValidation !== true ) {
228                return;
229            }
230
231            if( ! $(this).hasClass('ays-quiz-after-timer-end') ){
232                var confirm = true;
233                myOptions.enable_see_result_confirm_box = ! myOptions.enable_see_result_confirm_box ? 'off' : myOptions.enable_see_result_confirm_box;
234                var enable_see_result_confirm_box = (myOptions.enable_see_result_confirm_box && myOptions.enable_see_result_confirm_box == 'on') ? true : false;
235                if (enable_see_result_confirm_box) {
236                    if ( ! window.aysEarlyFinishConfirmBox[ quizId ] ) {
237                        confirm = window.confirm(quizLangObj.areYouSure);
238                        window.aysSeeResultConfirmBox[ quizId ] = false;
239                    }
240                }
241
242                if ( ! confirm ) {
243                    window.aysSeeResultConfirmBox[ quizId ] = true;
244                    return false;
245                }
246            }
247
248            if($(document).scrollTop() >= $(this).parents('.ays-questions-container').offset().top){
249                ays_quiz_container.goTo(myOptions);
250            }
251
252            if(ays_quiz_container.find('.ays_music_sound').length !== 0){
253                ays_quiz_container.find('.ays_music_sound').fadeOut();
254                setTimeout(function() {
255                    audioVolumeOut(ays_quiz_container.find('audio.ays_quiz_music').get(0));
256                },4000);
257                setTimeout(function() {
258                    ays_quiz_container.find('audio.ays_quiz_music').get(0).pause();
259                },6000);
260            }
261            if(ays_quiz_container.find('audio').length > 0){
262                ays_quiz_container.find('audio').each(function(e, el){
263                    el.pause();
264                });
265            }
266            if(ays_quiz_container.find('video').length > 0){
267                ays_quiz_container.find('video').each(function(e, el){
268                    el.pause();
269                });
270            }
271
272            if ('speechSynthesis' in window) {
273                speechSynthesis.cancel();
274            }
275
276            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
277            var enableNavigationBar = (myOptions.enable_navigation_bar && myOptions.enable_navigation_bar == "on") ? true : false;
278            var aysQuestionCountPerPage = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page');
279            var next_sibilings_count = aysQuestionCountPerPage.length > 0 ? parseInt( aysQuestionCountPerPage.val() ) : null;
280
281            if( ! $(this).hasClass('ays-quiz-after-timer-end') && ! window.aysEarlyFinishConfirmBox[ quizId ] ){
282                if(isRequiredQuestion === true && next_sibilings_count !== null ){
283                    ays_quiz_is_question_required( ays_quiz_container.find('.step') );
284                    if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
285                        return false;
286                    }
287                } else if (isRequiredQuestion === true && next_sibilings_count === null) {
288                    if ( enableNavigationBar ) {
289                        ays_quiz_is_question_required( ays_quiz_container.find('.step') );
290                        if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
291                            return false;
292                        }
293                    }
294                }
295            }
296
297            ays_quiz_container.find('.ays-live-bar-wrap').addClass('bounceOut');
298            setTimeout(function () {
299                ays_quiz_container.find('.ays-live-bar-wrap').css('display','none');
300            },300);
301
302            var isRequiredQuestion = (myOptions.make_questions_required && myOptions.make_questions_required == "on") ? true : false;
303            var aysQuestionCountPerPage = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page');
304            var next_sibilings_count = aysQuestionCountPerPage.length > 0 ? parseInt( aysQuestionCountPerPage.val() ) : null;
305            var isTimerEnabled = (myOptions.enable_timer && myOptions.enable_timer == "on") ? true : false;
306
307            if( ! $(this).hasClass('ays-quiz-after-timer-end') && ! window.aysEarlyFinishConfirmBox[ quizId ] ){
308                if(isRequiredQuestion === true && next_sibilings_count !== null ){
309                    ays_quiz_is_question_required( ays_quiz_container.find('.step') );
310                    if( ays_quiz_container.hasClass('ays-quiz-has-error') ){
311                        return false;
312                    }
313                }
314            }
315
316            var emailValivatePattern = /^[a-zA-Z0-9\._+-]+@[a-zA-Z0-9\._-]+\.\w{2,}$/;
317
318            if (!($(this).hasClass('start_button'))) {
319                if ($(this).parents('.step').find('input[required]').length !== 0 ||
320                    $(this).parents('.step').find('select.ays_quiz_form_input[required]').length !== 0) {
321                    var empty_inputs = 0;
322                    var required_inputs = $(this).parents('.step').find('input[required]');
323                    $(this).parents('.step').find('.ays_red_border').removeClass('ays_red_border');
324                    $(this).parents('.step').find('.ays_green_border').removeClass('ays_green_border');
325                    for (var i = 0; i < required_inputs.length; i++) {
326                        switch(required_inputs.eq(i).attr('type')){
327                            case "checkbox": {
328                                if(required_inputs.eq(i).prop('checked') === false){
329                                    required_inputs.eq(i).addClass('ays_red_border');
330                                    required_inputs.eq(i).addClass('shake');
331                                    empty_inputs++;
332                                }else{
333                                    required_inputs.eq(i).addClass('ays_green_border');
334                                }
335                                break;
336                            }
337                            case "email": {
338                                if (!(emailValivatePattern.test(required_inputs.eq(i).val()))) {
339                                    required_inputs.eq(i).addClass('ays_red_border');
340                                    required_inputs.eq(i).addClass('shake');
341                                    empty_inputs++;
342                                }else{
343                                    required_inputs.eq(i).addClass('ays_green_border');
344                                }
345                                break;
346                            }
347                            case "tel": {
348                                if (!validatePhoneNumber(required_inputs.eq(i).get(0))) {
349                                    required_inputs.eq(i).addClass('ays_red_border');
350                                    required_inputs.eq(i).addClass('shake');
351                                    empty_inputs++;
352                                }else{
353                                    required_inputs.eq(i).addClass('ays_green_border');
354                                }
355                                break;
356                            }
357                            case "file": {
358                                var fileParentDiv = required_inputs.eq(i).parents('.ays-quiz-upload-type-main');
359                                var hiddenInputFileValue = fileParentDiv.find('.ays-quiz-upload-ready-url-link').val();
360                                if (! hiddenInputFileValue ) {
361                                    fileParentDiv.addClass('ays_red_border');
362                                    fileParentDiv.addClass('shake');
363                                    empty_inputs++;
364                                }else{
365                                    fileParentDiv.addClass('ays_green_border');
366                                }
367                                break;
368                            }
369                            default:{
370                                if (required_inputs.eq(i).val() === '' &&
371                                    required_inputs.eq(i).attr('type') !== 'hidden') {
372                                    required_inputs.eq(i).addClass('ays_red_border');
373                                    required_inputs.eq(i).addClass('shake');
374                                    empty_inputs++;
375                                }else{
376                                    required_inputs.eq(i).addClass('ays_green_border');
377                                }
378                                if(required_inputs.eq(i).attr('name') == "ays_user_email" && !(emailValivatePattern.test(required_inputs.eq(i).val()))){
379                                    empty_inputs++;
380                                }
381                                break;
382                            }
383                        }
384                    }
385                    var empty_inputs2 = 0;
386                    var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]');
387                    var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]');
388                    var selectAttr = $(this).parents('.step').find('select.ays_quiz_form_input[required]');
389                    if(phoneInput.val() != ''){
390                        phoneInput.removeClass('ays_red_border');
391                        phoneInput.removeClass('ays_green_border');
392                        if (!validatePhoneNumber(phoneInput.get(0))) {
393                            if (phoneInput.attr('type') !== 'hidden') {
394                                phoneInput.addClass('ays_red_border');
395                                phoneInput.addClass('shake');
396                                empty_inputs2++;
397                            }
398                        }else{
399                            phoneInput.addClass('ays_green_border');
400                        }
401                    }
402                    if(selectAttr.val() == ''){
403                        selectAttr.removeClass('ays_red_border');
404                        selectAttr.removeClass('ays_green_border');
405
406                        selectAttr.addClass('ays_red_border');
407                        selectAttr.addClass('shake');
408                        empty_inputs++;
409                    }else{
410                        selectAttr.removeClass('ays_red_border');
411                    }
412                    var errorFields = $(this).parents('.step').find('.ays_red_border');
413                    if (empty_inputs2 !== 0 || empty_inputs !== 0) {
414                        setTimeout(function(){
415                            errorFields.each(function(){
416                                $(this).removeClass('shake');
417                            });
418                        }, 500);
419                        setTimeout(function(){
420                            required_inputs.each(function(){
421                                $(this).removeClass('shake');
422                            });
423                        }, 500);
424                        return false;
425                    }
426                }else{
427                    if($(this).parents('.step').find('.information_form').length !== 0 ){
428                        var empty_inputs = 0;
429                        var phoneInput = $(this).parents('.step').find('input[name="ays_user_phone"]');
430                        var emailInput = $(this).parents('.step').find('input[name="ays_user_email"]');
431                        var emailInputs = $(this).parents('.step').find('input[type="email"]');
432                        if(phoneInput.val() != ''){
433                            phoneInput.removeClass('ays_red_border');
434                            phoneInput.removeClass('ays_green_border');
435                            if (!validatePhoneNumber(phoneInput.get(0))){
436                                if (phoneInput.attr('type') !== 'hidden') {
437       
437                             phoneInput.addClass('ays_red_border');
438                                    phoneInput.addClass('shake');
439                                    empty_inputs++;
440                                }
441                            }else{
442                                phoneInput.addClass('ays_green_border');
443                            }
444                        }
445                        if(emailInput.val() != ''){
446                            emailInput.removeClass('ays_red_border');
447                            emailInput.removeClass('ays_green_border');
448                            if (!(emailValivatePattern.test(emailInput.val()))) {
449                                if (emailInput.attr('type') !== 'hidden') {
450                                    emailInput.addClass('ays_red_border');
451                                    emailInput.addClass('shake');
452                                    empty_inputs++;
453                                }
454                            }else{
455                                emailInput.addClass('ays_green_border');
456                            }
457                        }
458
459                        emailInputs.each(function(){
460                            var thisEmailInput = $(this);
461                            if(thisEmailInput.val() != ''){
462                                thisEmailInput.removeClass('ays_red_border');
463                                thisEmailInput.removeClass('ays_green_border');
464                                if (!(emailValivatePattern.test(thisEmailInput.val()))) {
465                                    thisEmailInput.addClass('ays_red_border');
466                                    thisEmailInput.addClass('shake');
467                                    empty_inputs++;
468                                }else{
469                                    thisEmailInput.addClass('ays_green_border');
470                                }
471                            }
472                        });
473                        var errorFields = $(this).parents('.step').find('.ays_red_border');
474                        if (empty_inputs !== 0) {
475                            setTimeout(function(){
476                                errorFields.each(function(){
477                                    $(this).removeClass('shake');
478                                });
479                            }, 500);
480                            return false;
481                        }
482                    }
483                }
484            }
485
486            next_fs = $(this).parents('.step').next();
487            current_fs = $(this).parents('.step');
488            form = ays_quiz_container.find('form.ays-quiz-form');
489
490            if (!($(this).hasClass('start_button')) && ! $(this).hasClass('ays-quiz-after-timer-end') && ! window.aysEarlyFinishConfirmBox[ quizId ]) {
491                var minSelHasError = 0;
492                var buttonsDiv = current_fs.find('.ays_buttons_div');
493                var enableArrows = $(this).parents(".ays-questions-container").find(".ays_qm_enable_arrows").val();
494                var timerBox = $(this).parents(".ays-quiz-container").find(".ays-quiz-timer div.ays-quiz-after-timer");
495                if( ays_quiz_container.find('.step[data-question-id] .enable_min_selection_number').length > 0 ){
496                    ays_quiz_container.find('.step[data-question-id] .enable_min_selection_number').each(function(){
497                        var MinSelQuestion = $(this).parents('.step[data-question-id]');
498                        var checkedMinSelCount = aysCheckMinimumCountCheckbox( MinSelQuestion, myQuizOptions );
499                        if( ays_quiz_is_question_min_count( MinSelQuestion, !checkedMinSelCount ) === true ){
500                            if( checkedMinSelCount == true ){
501                                if(enableArrows){
502                                    buttonsDiv.find('i.ays_next_arrow').removeAttr('disabled');
503                                    buttonsDiv.find('i.ays_next_arrow').prop('disabled', false);
504                                }else{
505                                    buttonsDiv.find('input.ays_next').removeAttr('disabled');
506                                    buttonsDiv.find('input.ays_next').prop('disabled', false);
507                                }
508                            }else{
509                                if(enableArrows){
510                                    buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
511                                    buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
512                                    buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
513                                }else{
514                                    buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
515                                    buttonsDiv.find('input.ays_next').prop('disabled', true);
516                                    buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
517                                }
518                                minSelHasError++;
519
520                                if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
521                                    if( myOptions.quiz_timer_type && ( myOptions.quiz_timer_type === 'question_timer' || myOptions.quiz_timer_type === 'quiz_timer') ){
522
523                                        var c_qid = checkChecboxQuestionTimerForSubmitQuiz(ays_quiz_container, quizId, MinSelQuestion);
524                                        if (c_qid !== false) {
525                                            checkboxMinCountAndNavigationFlag = true;
526                                            // ays_quiz_container.find('.ays_questions_nav_question[data-id="' + c_qid + '"]').trigger('click');
527                                        } else if( c_qid === false && minSelHasError > 0 ) {
528                                            checkboxMinCountAndNavigationFlag = true;
529                                        }
530                                    }
531                                }
532                            }
533                        }else{
534                            if(enableArrows){
535                                buttonsDiv.find('i.ays_next_arrow').attr('disabled', 'disabled');
536                                buttonsDiv.find('i.ays_next_arrow').prop('disabled', true);
537                                buttonsDiv.find('i.ays_next_arrow').removeClass('ays_display_none');
538                            }else{
539                                buttonsDiv.find('input.ays_next').attr('disabled', 'disabled');
540                                buttonsDiv.find('input.ays_next').prop('disabled', true);
541                                buttonsDiv.find('input.ays_next').removeClass('ays_display_none');
542                            }
543                            minSelHasError++;
544
545                            if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
546                                if( myOptions.quiz_timer_type && ( myOptions.quiz_timer_type === 'question_timer' || myOptions.quiz_timer_type === 'quiz_timer') ){
547
548                                    var c_qid = checkChecboxQuestionTimerForSubmitQuiz(ays_quiz_container, quizId, MinSelQuestion);
549                                    if (c_qid !== false) {
550                                        checkboxMinCountAndNavigationFlag = true;
551                                        // ays_quiz_container.find('.ays_questions_nav_question[data-id="' + c_qid + '"]').trigger('click');
552                                    }
553                                    else if( c_qid === false && minSelHasError > 0 ) {
554                                        if( myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'quiz_timer' ){
555                                            if( myOptions.make_questions_required && myOptions.make_questions_required === "off" ){
556                                                checkboxMinCountAndNavigationFlag = true;
557                                            }
558                                        }
559                                    }
560                                }
561                            }
562                        }
563                    });
564                }
565
566                var is_timerEnd = false;
567                if(isTimerEnabled){
568                    if(timerBox.hasClass("ays_timer_end")){
569                        is_timerEnd = true;
570                    }
571                }
572
573                if( minSelHasError > 0 && is_timerEnd){
574                    return false;
575                } else if( checkboxMinCountAndNavigationFlag ){
576                    return false;
577                } else if( !checkboxMinCountAndNavigationFlag && minSelHasError > 0 ){
578                    if( myOptions.enable_timer && myOptions.enable_timer === 'off' ) {
579                        return false;
580                    }
581                }
582            }
583
584            if (!($(this).hasClass('start_button')) && ! window.aysEarlyFinishConfirmBox[ quizId ]) {
585                if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
586                    if (myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'question_timer') {
587                        if (window.aysQuizQuestionTimers && window.aysQuizQuestionTimers[quizId]) {
588                            if( myOptions.enable_navigation_bar && myOptions.enable_navigation_bar === 'on' ) {
589                                if (myOptions.make_questions_required && myOptions.make_questions_required === "on") {
590                                    var qid = checkQuestionTimer(ays_quiz_container, quizId);
591                                    if (qid !== false) {
592                                        ays_quiz_container.find('.ays_questions_nav_question[data-id="' + qid + '"]').trigger('click');
593                                        ays_quiz_is_question_required( ays_quiz_container.find('.step[data-question-id="' + qid + '"]') );
594                                        return;
595                                    } else {
596                                        if( checkboxMinCountAndNavigationFlag && qid === false ){
597                                            return false;
598                                        }
599                                        for ( var questionID in window.aysQuizQuestionTimers[quizId] ) {
600                                            stopQuestionTimer( questionID, quizId, myOptions );
601                                        }
602                                    }
603                                }else{
604                                    if( checkboxMinCountAndNavigationFlag ){
605                                        return false;
606                                    }
607                                    for ( var questionID in window.aysQuizQuestionTimers[quizId] ) {
608                                        stopQuestionTimer( questionID, quizId, myOptions );
609                                    }
610                                }
611                            }else{
612                                if( checkboxMinCountAndNavigationFlag ){
613                                    return false;
614                                }
615                                for ( var questionID in window.aysQuizQuestionTimers[quizId] ) {
616                                    stopQuestionTimer( questionID, quizId, myOptions );
617                                }
618                            }
619                        } else {
620                            if( checkboxMinCountAndNavigationFlag ){
621                                if( !$(this).hasClass('ays-quiz-after-timer-end') ){
622                                    return false;
623                                }
624                            }
625                        }
626                    } else {
627                        if( checkboxMinCountAndNavigationFlag ){
628                            if( !$(this).hasClass('ays-quiz-after-timer-end') ){
629                                return false;
630                            }
631                        }
632                    }
633                }
634            } else if( window.aysEarlyFinishConfirmBox[ quizId ] ){
635                if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
636                    if (myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'question_timer') {
637                        if (window.aysQuizQuestionTimers && window.aysQuizQuestionTimers[quizId]) {
638                            if( myOptions.enable_navigation_bar && myOptions.enable_navigation_bar === 'on' ) {
639                                if (myOptions.make_questions_required && myOptions.make_questions_required === "on") {
640                                    for ( var questionID in window.aysQuizQuestionTimers[quizId] ) {
641                                        stopQuestionTimer( questionID, quizId, myOptions );
642                                    }
643                                }
644                            }
645                        }
646                    }
647                }
648            }
649
650            next_fs.addClass('active-step');
651            current_fs.removeClass('active-step');
652
653            var next_sibilings_count = $(this).parents('form.ays-quiz-form').find('.ays_question_count_per_page').val();
654            $(e.target).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', false);
655            $(e.target).parents().eq(3).find('div.ays-quiz-timer').slideUp(500);
656            if($(e.target).parents().eq(3).find('div.ays-quiz-after-timer').hasClass('empty_after_timer_text')){
657                $(e.target).parents().eq(3).find('div.ays-quiz-timer').parent().slideUp(500);
658            }
659
660            var textAnswers = form.find('div.ays-text-field textarea.ays-text-input');
661            for(var i=0; i < textAnswers.length; i++){
662                var userAnsweredText = textAnswers.eq(i).val().trim();
663                var questionId = textAnswers.eq(i).parents('.step').data('questionId');
664
665                var trueAnswered = false;
666
667                // Enable case sensitive text
668                var enable_case_sensitive_text = (myQuizOptions[questionId].enable_case_sensitive_text && myQuizOptions[questionId].enable_case_sensitive_text != "") ? myQuizOptions[questionId].enable_case_sensitive_text : false;
669
670                var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer == '' ? "" : myQuizOptions[questionId].question_answer;
671                var thisQuestionAnswer = thisQuestionCorrectAnswer.toLowerCase();
672
673                if ( enable_case_sensitive_text ) {
674                    thisQuestionAnswer = thisQuestionCorrectAnswer;
675                }
676
677                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes().split('%%%');
678                for(var i_answer = 0; i_answer < thisQuestionAnswer.length; i_answer++){
679                    if ( enable_case_sensitive_text ) {
680                        if(userAnsweredText == thisQuestionAnswer[i_answer].trim()){
681                            trueAnswered = true;
682                            break;
683                        }
684                    } else {
685                        if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i_answer].trim()){
686                            trueAnswered = true;
687                            break;
688                        }
689                    }
690                }
691
692                if(trueAnswered){
693                    textAnswers.eq(i).next().val(1);
694                }else{
695                    textAnswers.eq(i).next().val(0);
696                    if(thisQuestionCorrectAnswer == ''){
697                        textAnswers.eq(i).attr('chishtpatasxan', '-');
698                    }else{
699                        textAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer);
700                    }
701                }
702                textAnswers.eq(i).removeAttr('disabled');
703            }
704            
705            var numberAnswers = form.find('div.ays-text-field input[type="number"].ays-text-input');
706            for(var i=0; i < numberAnswers.length; i++){
707                va
707r userAnsweredText = numberAnswers.eq(i).val().trim();
708                var questionId = numberAnswers.eq(i).parents('.step').data('questionId');
709                if(userAnsweredText.toLowerCase().replace(/\.([^0]+)0+$/,".$1") === myQuizOptions[questionId].question_answer.toLowerCase().replace(/\.([^0]+)0+$/,".$1")){
710                    numberAnswers.eq(i).next().val(1);
711                }else{
712                    numberAnswers.eq(i).next().val(0);
713                    numberAnswers.eq(i).attr('chishtpatasxan', myQuizOptions[questionId].question_answer);
714                }
715                numberAnswers.eq(i).removeAttr('disabled')
716            }
717            
718            var shortTextAnswers = form.find('div.ays-text-field input[type="text"].ays-text-input');
719            for(var i=0; i < shortTextAnswers.length; i++){
720                var userAnsweredText = shortTextAnswers.eq(i).val().trim();
721                var questionId = shortTextAnswers.eq(i).parents('.step').data('questionId');
722
723                var trueAnswered = false;
724
725                // Enable case sensitive text
726                var enable_case_sensitive_text = (myQuizOptions[questionId].enable_case_sensitive_text && myQuizOptions[questionId].enable_case_sensitive_text != "") ? myQuizOptions[questionId].enable_case_sensitive_text : false;
727
728                var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer == '' ? "" : myQuizOptions[questionId].question_answer;
729                var thisQuestionAnswer = thisQuestionCorrectAnswer.toLowerCase();
730
731                if ( enable_case_sensitive_text ) {
732                    thisQuestionAnswer = thisQuestionCorrectAnswer;
733                }
734
735                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes().split('%%%');
736                for(var i_answer = 0; i_answer < thisQuestionAnswer.length; i_answer++){
737                    if ( enable_case_sensitive_text ) {
738                        if(userAnsweredText == thisQuestionAnswer[i_answer].trim()){
739                            trueAnswered = true;
740                            break;
741                        }
742                    } else {
743                        if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i_answer].trim()){
744                            trueAnswered = true;
745                            break;
746                        }
747                    }
748                }
749
750                if(trueAnswered){
751                    shortTextAnswers.eq(i).next().val(1);
752                }else{
753                    shortTextAnswers.eq(i).next().val(0);
754                    if(thisQuestionCorrectAnswer == ''){
755                        shortTextAnswers.eq(i).attr('chishtpatasxan', '-');
756                    }else{
757                        shortTextAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer);
758                    }
759                }
760
761                shortTextAnswers.eq(i).removeAttr('disabled')
762            }
763
764            var fillInBlankAnswers = form.find('div.ays_quiz_question input[type="text"].ays-text-input.ays-quiz-fill-in-blank-input');
765            for(var i=0; i < fillInBlankAnswers.length; i++){
766                var userAnsweredText = fillInBlankAnswers.eq(i).val().trim();
767                var answerID = fillInBlankAnswers.eq(i).attr('data-answer-id');
768                var questionId = fillInBlankAnswers.eq(i).parents('.step').data('questionId');
769
770                var trueAnswered = false;
771
772                // Enable case sensitive text
773                var enable_case_sensitive_text = (myQuizOptions[questionId].enable_case_sensitive_text && myQuizOptions[questionId].enable_case_sensitive_text != "") ? myQuizOptions[questionId].enable_case_sensitive_text : false;
774
775                var thisQuestionCorrectAnswer_Arr = myQuizOptions[questionId].question_answer.length > 0 ? "" : myQuizOptions[questionId].question_answer;
776
777                var thisQuestionCorrectAnswer = thisQuestionCorrectAnswer_Arr[answerID];
778                var thisQuestionAnswer = thisQuestionCorrectAnswer.toLowerCase();
779
780                if ( enable_case_sensitive_text ) {
781                    thisQuestionAnswer = thisQuestionCorrectAnswer;
782                }
783
784                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes().split('%%%');
785                for(var i_answer = 0; i_answer < thisQuestionAnswer.length; i_answer++){
786                    if ( enable_case_sensitive_text ) {
787                        if(userAnsweredText == thisQuestionAnswer[i_answer].trim()){
788                            trueAnswered = true;
789                            break;
790                        }
791                    } else {
792                        if(userAnsweredText.toLowerCase() == thisQuestionAnswer[i_answer].trim()){
793                            trueAnswered = true;
794                            break;
795                        }
796                    }
797                }
798
799                if(trueAnswered){
800                    fillInBlankAnswers.eq(i).next().val(1);
801                }else{
802                    fillInBlankAnswers.eq(i).next().val(0);
803                    if(thisQuestionCorrectAnswer == ''){
804                        fillInBlankAnswers.eq(i).attr('chishtpatasxan', '-');
805                    }else{
806                        fillInBlankAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer);
807                    }
808                }
809
810                fillInBlankAnswers.eq(i).removeAttr('disabled');
811
812            }
813
814            var fillInBlankAnswersHTML = form.find('div.step[data-type="fill_in_blank"]');
815            if( fillInBlankAnswersHTML.length > 0 ){
816                for(var i=0; i < fillInBlankAnswersHTML.length; i++){
817                    var fill_in_blank_answer_html = $( fillInBlankAnswersHTML[i] );
818                    if( fill_in_blank_answer_html.find('div.ays-quiz-answers').length > 0){
819                        fill_in_blank_answer_html.find('div.ays-quiz-answers').remove();
820                    }
821
822                    if( fill_in_blank_answer_html.find('div.ays_buttons_div.ays_buttons_div_for_fill_in_blank').length > 0){
823                        fill_in_blank_answer_html.find('div.ays_buttons_div.ays_buttons_div_for_fill_in_blank').remove();
824                    }
825                }
826            }
827            
828
829            var dateAnswers = form.find('div.ays-text-field input[type="date"].ays-text-input');
830            for(var i=0; i < dateAnswers.length; i++){
831                var userAnsweredText = dateAnswers.eq(i).val();
832                var questionId = dateAnswers.eq(i).parents('.step').data('questionId');
833                var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer == '' ? "" : myQuizOptions[questionId].question_answer;
834
835                var trueAnswered = false;
836                var correctDate = new Date(thisQuestionCorrectAnswer),
837                    correctDateYear = correctDate.getFullYear(),
838                    correctDateMonth = correctDate.getMonth(),
839                    correctDateDay = correctDate.getDate();
840                var userDate = new Date(userAnsweredText),
841                    userDateYear = userDate.getFullYear(),
842                    userDateMonth = userDate.getMonth(),
843                    userDateDay = userDate.getDate();
844
845                if(correctDateYear == userDateYear && correctDateMonth == userDateMonth && correctDateDay == userDateDay){
846                    trueAnswered = true;
847                }
848
849                if(trueAnswered){
850                    dateAnswers.eq(i).next().val(1);
851                }else{
852                    dateAnswers.eq(i).next().val(0);
853                    if(thisQuestionCorrectAnswer == ''){
854                        dateAnswers.eq(i).attr('chishtpatasxan', '-');
855                    }else{
856                        dateAnswers.eq(i).attr('chishtpatasxan', thisQuestionCorrectAnswer);
857                    }
858                }
859
860                dateAnswers.eq(i).removeAttr('disabled')
861            }
862
863
864            var data = form.serializeFormJSON();
865            var questionsIds = data.ays_quiz_questions.split(',');
866            
867            var questionsObjs = {};
868            form.find('div[data-question-id]').each(function (){
869                questionsObjs[$(this).data('questionId')] = $(this).data('type');
870            });
871
872            for(var i = 0; i < questionsIds.length; i++){
873                if( questionsObjs[ questionsIds[i] ] && questionsObjs[ questionsIds[i] ] !== 'matching' && questionsObjs[ questionsIds[i] ] !== 'fill_in_blank' ) {
874                    if (!data['ays_questions[ays-question-' + questionsIds[i] + ']']) {
875                        data['ays_questions[ays-question-' + questionsIds[i] + ']'] = "";
876                    }
877                }
878            }
879
880            var checked_inputs_arr = ays_quiz_container.find(".step .ays-field input[id*='ays-answer-']:checked");
881            if ( checked_inputs_arr.length > 0 ) {
882                checked_inputs_arr.each(function () {
883                    var checked_input = $(this);
884                    var parent = checked_input.parents('.step');
885                    var checked_input_name  = checked_input.attr('name');
886                    var checked_input_value = checked_input.attr('value');
887
888                    var questionId = parent.attr('data-question-id');
889                    var answerId = checked_input.val();
890
891                    if( typeof questionId != "undefined" && questionId !== null ){
892
893                        var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer.length <= 0 ? array() : myQuizOptions[questionId].question_answer;
894                        var ifCorrectAnswer = thisQuestionCorrectAnswer[answerId] == '' ? '' : thisQuestionCorrectAnswer[answerId];
895                        if( typeof ifCorrectAnswer != "undefined" ){
896                            checked_input.parents('.ays-field').find('input[name="ays_answer_
896correct[]"]').val(ifCorrectAnswer);
897                        }
898
899                        if (checked_input_name != "" && checked_input_value != "") {
900                            if ( data[checked_input_name] !== undefined && data[checked_input_name] == "") {
901                                data[checked_input_name] = checked_input_value;
902                            }
903                        }
904                    }
905                });
906
907                var newData = form.serializeFormJSON();
908                var ays_answer_correct_data = typeof newData["ays_answer_correct[]"] != "undefined" ? newData["ays_answer_correct[]"] : new Array();
909                if(typeof ays_answer_correct_data != "undefined" && ays_answer_correct_data.length > 0){
910                    data['ays_answer_correct[]'] = ays_answer_correct_data;
911                }
912            }
913
914            var selected_options_arr = ays_quiz_container.find(".step .ays-field select");
915            if ( selected_options_arr.length > 0 ) {
916                selected_options_arr.each(function (element, item) {
917                    var selected_options = $(this);
918                    var selectOptions = $(item).children("option[data-chisht]");
919
920                    var parent = selected_options.parents('.step');
921                    var fieldParent = parent.find('.ays-field');
922                    var fieldParentInput = fieldParent.find('input.ays-select-field-value');
923                    var checked_input_name  = fieldParentInput.attr('name');
924                    var checked_input_value = fieldParentInput.attr('value');
925
926                    var questionId = parent.attr('data-question-id');
927                    for(var j = 0; j < selectOptions.length; j++){
928                        var currnetSelectOption = $(selectOptions[j]);
929                        var answerId = currnetSelectOption.val();
930
931                        if( typeof questionId != "undefined" && questionId !== null ){
932
933                            var thisQuestionCorrectAnswer = myQuizOptions[questionId].question_answer.length <= 0 ? new Array() : myQuizOptions[questionId].question_answer;
934                            var ifCorrectAnswer = thisQuestionCorrectAnswer[answerId] == '' ? '' : thisQuestionCorrectAnswer[answerId];
935                            if( typeof ifCorrectAnswer != "undefined" ){
936                                fieldParent.find('input[data-id="'+ answerId +'"][name="ays_answer_correct[]"]').val(ifCorrectAnswer);
937                                currnetSelectOption.attr('data-chisht', ifCorrectAnswer);
938                            }
939                        }
940
941                    }
942
943                    if( typeof questionId != "undefined" && questionId !== null ){
944
945                        if (checked_input_name != "" && checked_input_value != "") {
946                            if ( data[checked_input_name] !== undefined && data[checked_input_name] == "") {
947                                data[checked_input_name] = checked_input_value;
948                            }
949                        }
950                    }
951                });
952
953                var newData = form.serializeFormJSON();
954                var ays_answer_correct_data = typeof newData["ays_answer_correct[]"] != "undefined" ? newData["ays_answer_correct[]"] : new Array();
955                if(typeof ays_answer_correct_data != "undefined" && ays_answer_correct_data.length > 0){
956                    data['ays_answer_correct[]'] = ays_answer_correct_data;
957                }
958            }
959            
960            // $(this).parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').css("display", "none");
961            ays_quiz_container.find('.ays-quiz-questions-nav-wrap').css("display", "none");
962
963            data.action = 'ays_finish_quiz';
964            data.end_date = GetFullDateTime();
965            var ays_quiz_finish_time = ays_quiz_container.find('.ays-quiz-end-date');
966            if ( ays_quiz_finish_time.length !== 0 && ays_quiz_finish_time.val() != "" ) {
967                data.end_date = ays_quiz_finish_time.val();
968            } else {
969                data.end_date = GetFullDateTime();
970            }
971
972            if ( typeof data.start_date == "undefined" || data.start_date == "" ) {
973                data.start_date = window.aysQuizStartDate;
974            }
975
976            if ( typeof data.end_date == "undefined" || data.end_date == "" ) {
977                data.end_date = GetFullDateTime();
978            }
979
980            if (window.location != window.parent.location) {
981                if ( typeof data.ays_quiz_curent_page_link != "undefined" && data.ays_quiz_curent_page_link != "" ) {
982                    if ( data.ays_quiz_curent_page_link.indexOf("action=ays_quiz_iframe_shortcode") > 0 ) {
983                        if( window.aysQuizParentWindowLink && window.aysQuizParentWindowLink != ""){
984                            data.ays_quiz_curent_page_link = window.aysQuizParentWindowLink;
985                        }
986                    }
987                }
988            }
989            
990            var aysQuizLoader = form.find('div[data-role="loader"]');
991            aysQuizLoader.addClass(aysQuizLoader.data('class'));
992            aysQuizLoader.removeClass('ays-loader');
993
994            var animationOptions = {
995                scale: scale,
996                left: left,
997                opacity: opacity,
998                animating: animating
999            }
1000            
1001            setTimeout(function () {
1002                sendQuizData(data, form, myOptions, myQuizOptions, animationOptions, $(e.target));
1003            },2000);
1004            
1005            if (parseInt(next_sibilings_count) > 0 && ($(this).parents('.step').attr('data-question-id') || $(this).parents('.step').next().attr('data-question-id'))) {
1006                current_fs = $(this).parents('form.ays-quiz-form').find('div[data-question-id]');
1007            }
1008            
1009            if( isRequiredQuestion ) {
1010                var qid = checkQuestionTimer(ays_quiz_container, quizId);
1011                if ( qid === false ){
1012                    aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
1013                }else if( window.aysEarlyFinishConfirmBox[ quizId ] ){
1014                    aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
1015                }
1016            } else if( myOptions.enable_timer && myOptions.enable_timer === 'on' ){
1017                if( (myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'question_timer' && !checkboxMinCountAndNavigationFlag) || $(this).hasClass('ays-quiz-after-timer-end') ){
1018                    aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
1019                }else if( window.aysEarlyFinishConfirmBox[ quizId ] ){
1020                    aysAnimateStep(ays_quiz_container.data('questEffect'), current_fs, next_fs);
1021                }
1022            }
1023        });
1024
1025        $(document).find('.ays_next.start_button').on('click',function(e){
1026            var $this = $(this);
1027            var thisCont = $this.parents('.ays-quiz-container');
1028            var quizId = thisCont.find('input[name="ays_quiz_id"]').val();
1029            var myOptions = JSON.parse(window.atob(window.aysQuizOptions[quizId]));
1030            var checkQuizGeneratedPassword = checkQuizPassword(e, myOptions, false);
1031            if(checkQuizGeneratedPassword){
1032                if(myOptions.enable_password && myOptions.enable_password == 'on'){
1033                    if(myOptions.generate_password && myOptions.generate_password == 'generated_password'){
1034                        var userGeneratedPasswordVal = $this.parents('.ays-quiz-container').find('.ays_quiz_password').val();
1035                        var userData = {};
1036                        userData.action = 'ays_generated_used_passwords';
1037                        userData.userGeneratedPassword = userGeneratedPasswordVal;
1038                        userData.quizId = quizId;
1039                        $.ajax({
1040                            url: quiz_maker_ajax_public.ajax_url,
1041                            method: 'post',
1042                            dataType: 'json',
1043                            crossDomain: true,
1044                            data: userData,
1045                            success: function (response) {
1046                                if(response.status){
1047                                }
1048                            }
1049                        });
1050                    }
1051                }
1052
1053                if(myOptions.limit_users && myOptions.limit_users == 'on'){
1054                    var limit_users_by = (myOptions.limit_users_by && myOptions.limit_users_by != '') ? myOptions.limit_users_by : 'ip';
1055                    var isUserLoggedIn = (myOptions.is_user_logged_in && myOptions.is_user_logged_in != null) ? myOptions.is_user_logged_in : null;
1056
1057                    myOptions.enable_restriction_pass = myOptions.enable_restriction_pass ? myOptions.enable_restriction_pass : 'off';
1058                    var onlyForSelectedUserRole = (myOptions.enable_restriction_pass && myOptions.enable_restriction_pass == 'on' ) ? true : false;
1059
1060                    myOptions.turn_on_extra_security_check = myOptions.turn_on_extra_security_check ? myOptions.turn_on_extra_security_check : 'on';
1061                    var turnOnSecurityCheck = (myOptions.turn_on_extra_security_check && myOptions.turn_on_extra_security_check == 'on' ) ? true : false;
1062
1063                    myOptions.limit_attempts_count_by_user_role = myOptions.limit_attempts_count_by_user_role ? myOptions.limit_attempts_count_by_user_role : '';
1064                    var limitAttemptsCountByUserRole = (myOptions.limit_attempts_count_by_user_role !=='' ) ? parseInt( myOptions.limit_attempts_count_by_user_role ) : '';
1065
1066                    if( isUserLoggedIn === null ){
1067                        isUserLoggedIn = false;
1068                    }
1069
1070                    var checkLimit = false;
1071                    if( limit_users_by != 'user_id' ){
1072                        checkLimit = true;
1073                    }
1074
1075                    if( isUserLoggedIn ){
1076                        checkLimit = true;
1077                    }
1078
1079                    if( turnOnSecurityCheck === false ){
1080                        checkLimit = false;
1081                    }
1082
1083                    if( checkLimit ){
1084                        var quiz_max_pass_count = (myOptions.quiz_max_pass_count && myOptions.quiz_max_pass_count != '') ? parseInt(myOptions.quiz_max_pass_count) : 1;
1085
1086                        if( limitAttemptsCountByUserRole !== '' && onlyForSelectedUserRole === true ){
1087                            quiz_max_pass_count = limitAttemptsCountByUserRole;
1088                        }
1089
1090                        // var limitation_message = (myOptions.limitation_message && myOptions.limitation_message != '') ? myOptions.limitation_message : quizLangObj.alreadyPassedQuiz;
1091                        var quiz_pass_score = (myOptions.quiz_pass_score && myOptions.quiz_pass_score != '') ? myOptions.quiz_pass_score : 0;
1092                        var text_color = (myOptions.text_color && myOptions.text_color != '') ? myOptions.text_color : "#333";
1093
1094                        // var html = '<div style="color:'+ text_color +';min-height:200px;" class="ays_block_content">'+ limitation_message +'</div>';
1095
1096                        var userData = {};
1097
1098                        userData.action = 'ays_quiz_check_user_started';
1099                        userData.quiz_id = quizId;
1100                        userData.quiz_max_pass_count = quiz_max_pass_count;
1101                        userData.quiz_pass_score = quiz_pass_score;
1102                        userData.start_date = GetFullDateTime();
1103
1104                        $.ajax({
1105                            url: quiz_maker_ajax_public.ajax_url,
1106                            method: 'post',
1107                            dataType: 'json',
1108                            crossDomain: true,
1109                            data: userData,
1110                            success: function (response) {
1111                                if(response.status){
1112                                    thisCont.find('.ays_quiz_result_row_id').val(response.result_id);
1113                                }else{
1114                                    var limitation_message = response.limitation_message;
1115                                    var html = '<div style="color:'+ text_color +';min-height:200px;" class="ays_block_content">'+ limitation_message +'</div>';
1116                                    
1117                                    $this.parents('.ays-quiz-wrap').find('.ays-quiz-questions-nav-wrap').hide();
1118                                    thisCont.find('.ays_quiz_timer_container').slideUp(500);
1119                                    thisCont.find('form.ays-quiz-form').append(html);
1120                                    thisCont.find('div.step').remove();
1121                                    clearInterval(window.aysTimerInterval);
1122                                }
1123                            }
1124                        });
1125                    }
1126                }
1127                else if( myOptions.store_all_not_finished_results && myOptions.store_all_not_finished_results === true ){
1128                    var quiz_max_pass_count = (myOptions.quiz_max_pass_count && myOptions.quiz_max_pass_count != '') ? parseInt(myOptions.quiz_max_pass_count) : 1;
1129                    var limitation_message = (myOptions.limitation_message && myOptions.limitation_message != '') ? myOptions.limitation_message : quizLangObj.alreadyPassedQuiz;
1130                    var quiz_pass_score = (myOptions.quiz_pass_score && myOptions.quiz_pass_score != '') ? myOptions.quiz_pass_score : 0;
1131                    var text_color = (myOptions.text_color && myOptions.text_color != '') ? myOptions.text_color : "#333";
1132
1133                    var html = '<div style="color:'+ text_color +';min-height:200px;" class="ays_block_content">'+ limitation_message +'</div>';
1134
1135                    var userData = {};
1136
1137                    userData.action = 'ays_quiz_check_user_started';
1138                    userData.quiz_id = quizId;
1139                    userData.quiz_max_pass_count = quiz_max_pass_count;
1140                    userData.quiz_pass_score = quiz_pass_score;
1141                    userData.start_date = GetFullDateTime();
1142
1143                    $.ajax({
1144                        url: quiz_maker_ajax_public.ajax_url,
1145                        method: 'post',
1146                        dataType: 'json',
1147                        crossDomain: true,
1148                        data: userData,
1149                        success: function (response) {
1150                            if(response.status){
1151                                thisCont.find('.ays_quiz_result_row_id').val(response.result_id);
1152                            }else{
1153                                clearInterval(window.aysTimerInterval);
1154                            }
1155                        }
1156                    });
1157                }
1158            }
1159
1160            if( myOptions.paypalStatus ){
1161                if( myOptions.paypalStatus.extraCheck === true ){
1162                    var userData = {};
1163
1164                    userData.action = 'ays_quiz_check_user_started_for_paypal';
1165                    userData.quiz_id = quizId;
1166                    userData.order_id = myOptions.paypalStatus.orderId;
1167                    userData.start_date = GetFullDateTime();
1168
1169                    $.ajax({
1170                        url: quiz_maker_ajax_public.ajax_url,
1171                        method: 'post',
1172                        dataType: 'json',
1173                        crossDomain: true,
1174                        data: userData
1175                    });
1176                }
1177            }
1178        });
1179
1180        $(document).on('click', '.ays-export-quiz-button', function (e) {
1181            var $this = $(this);
1182            var parent = $this.parents('.ays-quiz-container');
1183            var currentBoxParent = $this.parents('.ays-export-quiz-button-more-box');
1184            var quizId = parent.find('input[name="ays_quiz_id"]').val();
1185            var form   = parent.find('form.ays-quiz-form');
1186
1187            var dataAction = $this.attr('data-action');
1188            var action = 'user_export_quiz_questions_pdf';
1189            // var checkExportQuizAnswers = $(document).find('.ays-export-quiz-answers:checked').length;
1190            var exportQuizAnswers = (dataAction == 'quiz-with-questions') ? true : false;
1191
1192            var dataForExport = JSON.parse(window.atob(window.aysQuizUserExportDataArray[quizId]));
1193
1194            $this.parents('.ays-modal').find('div.ays-quiz-preloader').css('display', 'flex');
1195
1196            $.ajax({
1197                url: quiz_maker_ajax_public.ajax_url,
1198                method: 'post',
1199                dataType: 'json',
1200                data: {
1201                    action            : action,
1202                    dataForExport     : dataForExport,
1203                    exportQuizAnswers : exportQuizAnswers
1204                },
1205                success: function (response) {
1206                    if (response.status) {
1207                        $this.parent().find('#downloadFileU').attr({
1208                            'href': response.fileUrl,
1209                            'download': response.fileName,
1210                        })[0].click();
1211
1212                        window.URL.revokeObjectURL(response.fileUrl);
1213                    }else{
1214                        swal.fire({
1215                            type: 'info',
1216                            html: "<h2>Can't load resource.</h2><br><h4>Maybe the data has been deleted.</h4>",
1217                        })
1218                    }
1219                    $this.parents('.ays-modal').find('div.ays-quiz-preloader').css('display', 'none');
1220                    $this.removeClass('disabled');
1221                }
1222            });
1223
1224            if( currentBoxParent.hasClass('show-more-buttons') ){
1225                currentBoxParent.removeClass('show-more-buttons');
1226            }
1227            e.preventDefault();
1228        });
1229
1230        $(document).find(".ays-quiz-submit-question-report").on('click', function(e) {
1231            e.preventDefault();
1232            var _this = $(this);
1233            var parent = _this.parents(".ays-modal-reports");
1234            var reportForm = $(this).parents('form#ays-quiz-question-report-form');
1235
1236            var questionId = reportForm.find('input.ays-quiz-report-question-id').val();
1237            var quizId = reportForm.find('input.ays-quiz-report-quiz-id').val();
1238            var reportText = reportForm.find('textarea#ays-quiz-question-report-textarea').val();
1239            var sendEmail = reportForm.find('input.ays-quiz-report-question-send-email').val();
1240
1241            if (reportText === '') {
1242                var errorMessageDiv = reportForm.find('div.ays-quiz-question-report-error');
1243                errorMessageDiv.show();
1244
1245                setTimeout(function() {
1246                    errorMessageDiv.fadeOut(400, function() {
1247                        $(this).hide();
1248                    });
1249                }, 3000);
1250                return false;
1251            }
1252
1253            parent.find('div.ays-quiz-preloader').css('display', 'flex');
1254            parent.find('div.ays-quiz-preloader').addClass('ays_quiz_modal_overlay');
1255
1256            var data = {};
1257            data.action = 'ays_quiz_send_question_report';
1258            data.question_id = questionId;
1259            data.quiz_id = quizId;
1260            data.report_text = reportText;
1261            data.create_date = GetFullDateTime();
1262            data.send_email = sendEmail;
1263            $.ajax({
1264                url: quiz_maker_ajax_public.ajax_url,
1265                method: 'post',
1266                dataType: 'json',
1267                crossDomain: true,
1268                data: data,
1269                success: function (response) {
1270                    parent.find('div.ays-quiz-preloader').css('display', 'none');
1271                    parent.find('div.ays-quiz-preloader').removeClass('ays_quiz_modal_overlay');
1272
1273                    if(response.status) {
1274                        parent.hide();
1275
1276                        swal.fire({
1277                            type: 'success',
1278                            html: quizLangObj.reportSentMessage
1279                        });
1280                    }
1281                }
1282            });
1283        });
1284
1285        $(document).on('change', '.ays-quiz-upload-type-file', function(){
1286            var $this = $(this);
1287            var thisParent = $this.parents('.ays-quiz-upload-type-main');
1288            var typeError  = thisParent.find('.ays-quiz-upload-type-error-type');
1289            var sizeError  = thisParent.find('.ays-quiz-upload-type-error-size');
1290
1291            var thisCont = $this.parents('.ays-quiz-container');
1292            var quizId = thisCont.find('input[name="ays_quiz_id"]').val();
1293            var quizOptions = JSON.parse(window.atob(window.aysQuizOptions[quizId]));
1294            var attrOptions = quizOptions.attributes[ $this.data('slug') ];
1295
1296            var file = $this.prop("files")[0];
1297            if(typeof file != "undefined"){
1298                var currentFileName = file.name;
1299                var currentFileType = currentFileName.split('.').pop();
1300
1301                var fileSize = file.size;
1302                var fileSizeMb = ((fileSize/1024)/1024).toFixed(4);
1303                var fileAllowedSize = attrOptions.max_size;
1304
1305                var allExtentions = new Array("pdf", "doc", "docx", "png", "jpg", "jpeg", "gif");
1306                var allowedExtentions = new Array();
1307                if( attrOptions.allow_specific_types ){
1308                    for(var i = 0; i <= allExtentions.length - 1; i++){
1309                        var checker = allExtentions[i];
1310                        if( attrOptions.types[checker] && attrOptions.types[checker] === true ){
1311                            if(allExtentions[i] === "jpg"){
1312                                allowedExtentions.push("jpg" , "jpeg");
1313                            }else if(allExtentions[i] === "doc"){
1314                                allowedExtentions.push("doc" , "docx");
1315                            }else{
1316                                allowedExtentions.push(allExtentions[i]);
1317                            }
1318                        }
1319                    }
1320                }else{
1321                    allowedExtentions = allExtentions;
1322                }
1323
1324                if(allowedExtentions.indexOf(currentFileType.toLowerCase()) !== -1){
1325                    typeError.hide();
1326                    sizeError.hide();
1327                    if(+fileSizeMb <= +fileAllowedSize){
1328                        typeError.hide();
1329                        sizeError.hide();
1330                        var formData = new FormData();
1331                        formData.append('file', file);
1332                        formData.append('action', 'ays_quiz_attr_upload_file');
1333                        thisParent.find('.ays-quiz-upload-type-loader').show();
1334                        uploadFile(formData , thisParent , currentFileName);
1335                    }else{
1336                        typeError.hide();
1337                        sizeError.css("display" , "flex");
1338                    }
1339                }else{
1340                    typeError.css("display" , "flex");
1341                    sizeError.hide();
1342                }
1343                thisParent.find('.ays-quiz-upload-type-file').val("");
1344                setTimeout(function(){
1345                    typeError.hide();
1346                    sizeError.hide();
1347                }, 6000);
1348            }
1349        });
1350
1351        $(document).on('click', '.ays-quiz-upload-ready-image-box',function(){
1352            var $this = $(this);
1353            var $thisParent = $this.parents('.ays-quiz-upload-type-main');
1354            $thisParent.find('.ays-quiz-upload-ready').hide();
1355            $thisParent.find('.ays-quiz-upload-type').show();
1356            $thisParent.find('.ays-quiz-upload-ready-url-link').val("");
1357            $thisParent.find('.ays-quiz-upload-type-file').val("");
1358        });
1359
1360    });
1361    
1362    function sendQuizData(data, form, myOptions, myQuizOptions, options, element){
1363        if(typeof sendQuizData.counter == 'undefined'){
1364            sendQuizData.counter = 0;
1365        }
1366        if(window.navigator.onLine){
1367            sendQuizData.counter++;
1368            $.ajax({
1369                url: window.quiz_maker_ajax_public.ajax_url,
1370                method: 'post',
1371                dataType: 'json',
1372                crossDomain: true,
1373                data: data,
1374                success: function(response){
1375                    if(response.status === true){
1376                        doQuizResult(response, form, myOptions, myQuizOptions);
1377                    }else if( response.status === false && typeof response.flag !== 'undefined' && response.flag === false ){
1378                        var aysQuizContainer = element.parents('.ays-quiz-container');
1379                        var lastPageContent = '';
1380
1381                        lastPageContent += '<p>';
1382                            lastPageContent += response.text;
1383                        lastPageContent += '</p>';
1384
1385                        aysQuizContainer.find('.ays_thank_you_fs').html( lastPageContent );
1386                    }else{
1387                        if(sendQuizData.counter >= 5){
1388                            swal.fire({
1389                                type: 'error',
1390                            html: quizLangObj.sorry + ".<br>" + quizLangObj.unableStoreData + "."
1391                            });
1392                            goQuizFinishPage(form, options, element, myOptions);
1393                        }else{
1394                            if(window.navigator.onLine){
1395                                setTimeout(function(){
1396                                    sendQuizData(data, form, myOptions, myQuizOptions, options, element);
1397                                },3000);
1398                            }else{
1399                                sendQuizData(data, form, myOptions, myQuizOptions, options, element);
1400                            }
1401                        }
1402                    }
1403                },
1404                error: function(jqXHR, textStatus, errorThrown) {
1405                    if(sendQuizData.counter >= 5){
1406                        swal.fire({
1407                            type: 'error',
1408                            html: quizLangObj.sorry + ".<br>" + quizLangObj.unableStoreData + "."
1409                        });
1410                        goQuizFinishPage(form, options, element, myOptions);
1411                    }else{
1412                        setTimeout(function(){
1413                            sendQuizData(data, form, myOptions, myQuizOptions, options, element);
1414                        },3000);
1415                    }
1416                }
1417            });
1418        }else{
1419            swal.fire({
1420                type: 'warning',
1421                html: quizLangObj.connectionLost + ".<br>" + quizLangObj.checkConnection + "."
1422            });
1423            sendQuizData.counter = 0;
1424            goQuizFinishPage(form, options, element, myOptions);
1425            var aysQuizContainer = element.parents('.ays-quiz-container');
1426            aysQuizContainer.find('.step').hide();
1427            aysQuizContainer.find('.ays_thank_you_fs').prev().removeAttr('style').css({
1428                'display':'flex',
1429                'position':'static',
1430                'transform':'scale(1)',
1431                'opacity': 1,
1432                'pointer-events': 'auto'
1433            });
1434            var show_result_button = element.parents('form.ays-quiz-form').find('div[data-question-id] input[name="ays_finish_quiz"]');
1435            if (show_result_button.hasClass('ays_display_none')) {
1436                show_result_button.removeClass('ays_display_none');
1437            }
1438        }
1439    }
1440    
1441    function goQuizFinishPage(form, options, element, myOptions){        
1442        var currentFS = form.find('.step.active-step');
1443        var next_sibilings_count = form.find('.ays_question_count_per_page').val();
1444        if (parseInt(next_sibilings_count) > 0 &&
1445            (element.parents('.step').attr('data-question-id') ||
1446             element.parents('.step').next().attr('data-question-id'))) {
1447            currentFS = form.find('div[data-question-id]');
1448        }
1449        currentFS.prev().css('display', 'flex');
1450        currentFS.animate({opacity: 0}, {
1451            step: function(now, mx) {
1452                options.scale = 1 - (1 - now) * 0.2;
1453                options.left = (now * 50)+"%";
1454                options.opacity = 1 - now;
1455                currentFS.css({
1456                    'transform': 'scale('+options.scale+')',
1457                    'position': '',
1458                    'pointer-events': 'none'
1459                });
1460                currentFS.prev().css({
1461                    'left': options.left,
1462                    'opacity': options.opacity,
1463                    'pointer-events': 'none'
1464                });
1465            },
1466            duration: 800,
1467            complete: function(){
1468                currentFS.hide();
1469                currentFS.css({
1470                    'opacity': '1',
1471                    'pointer-events': 'auto',
1472                });
1473                currentFS.prev().css({
1474                    'transform': 'scale(1)',
1475                    'position': 'relative',
1476                    'opacity': '1',
1477                    'pointer-events': 'auto'
1478                });
1479                options.animating = false;
1480            },
1481            easing: 'easeInOutBack'
1482        });
1483        if(myOptions.enable_correction == 'on'){
1484            if(currentFS.prev().find('input:checked').length > 0){
1485                currentFS.prev().find('.ays-field input').attr('disabled', 'disabled');
1486                currentFS.prev().find('.ays-field input').on('click', function(){
1487                    return false;
1488                });
1489                currentFS.prev().find('.ays-field input').on('change', function(){
1490                    return false;
1491                });
1492            }
1493            if(currentFS.prev().find('option:checked').length > 0){
1494                currentFS.prev().find('.ays-field select').attr('disabled', 'disabled');
1495                currentFS.prev().find('.ays-field select').on('click', function(){
1496                    return false;
1497                });
1498                currentFS.prev().find('.ays-field select').on('change', function(){
1499                    return false;
1500                });
1501            }
1502            if(currentFS.prev().find('textarea').length > 0){
1503                if(currentFS.prev().find('textarea').val() !== ''){
1504                    currentFS.prev().find('.ays-field textarea').attr('disabled', 'disabled');
1505                    currentFS.prev().find('.ays-field textarea').on('click', function(){
1506                        return false;
1507                    });
1508                    currentFS.prev().find('.ays-field textarea').on('change', function(){
1509                        return false;
1510                    });
1511                }
1512            }
1513        }
1514    }
1515    
1516    function doQuizResult(response, form, myOptions, myQuizOptions){
1517        var hideQuizBGImage = form.parents('.ays-quiz-container').data('hideBgImage');
1518		var QuizBGGragient = form.parents('.ays-quiz-container').data('bgGradient');
1519        var quizId = form.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
1520        var uniqueCode = response.unique_code;
1521		if(hideQuizBGImage){
1522			form.parents('.ays-quiz-container').css('background-image', 'none');
1523			if(typeof QuizBGGragient != 'undefined'){
1524				form.parents('.ays-quiz-container').css('background-image', QuizBGGragient);
1525			}
1526		}
1527
1528        if(typeof response.chain_quiz_button_text != 'undefined' && response.chain_quiz_button_text === 'seeResult'){
1529            form.find('.ays_chain_see_result_button').removeClass('ays_display_none');
1530        }else if(typeof response.chain_quiz_button_text != 'undefined' && response.chain_quiz_button_text === 'nextQuiz'){
1531            form.find('.ays_chain_next_quiz_button').removeClass('ays_display_none');
1532        }
1533
1534        var conditionsData = response.conditionData;
1535        var conditionsExict = false;
1536        var conditionPageMessage = "";
1537        var conditionEmailMessage = "";
1538        var conditionRedirectDelay = "";
1539        var conditionRedirectUrl = "";
1540        var conditionRedirectCountDown = "";
1541        var trueConditionsCount = "";
1542        if(typeof conditionsData != "undefined"){
1543            if(conditionsData.hasAction){
1544                if(conditionsData.pageMessage){
1545                    conditionPageMessage = conditionsData.pageMessage;
1546                }
1547                if(conditionsData.emailMessage){
1548                    conditionEmailMessage = conditionsData.emailMessage;
1549                }
1550                if(conditionsData.redirectDelay){
1551                    conditionRedirectDelay = conditionsData.redirectDelay;
1552                }
1553                if(conditionsData.redirectUrl){
1554                    conditionRedirectUrl = conditionsData.redirectUrl;
1555                }
1556                if(conditionsData.redirectCountDown){
1557                    conditionRedirectCountDown = conditionsData.redirectCountDown;
1558                }
1559                if(conditionsData.trueConditionsCount){
1560                    trueConditionsCount = conditionsData.trueConditionsCount;
1561                }
1562                conditionsExict = true;
1563            }
1564        }
1565
1566        var ays_block_element = form.parents('.ays-quiz-container');
1567        var redirectActionResponse = true;
1568        if(conditionsExict){
1569            if(conditionRedirectUrl){
1570                redirectActionResponse = redirectAction(conditionRedirectUrl, conditionRedirectDelay, ays_block_element, conditionRedirectCountDown, form, myOptions, false, uniqueCode);
1571            }else{
1572                if(response.showIntervalMessage && ( response.interval_redirect_url !== null && response.interval_redirect_url != '' )){
1573                    redirectActionResponse = redirectAction(response.interval_redirect_url, response.interval_redirect_delay, ays_block_element, response.interval_redirect_after, form, myOptions, false, uniqueCode);
1574                }else{
1575                    if (myOptions.redirect_after_submit && myOptions.redirect_after_submit == 'on') {
1576                        redirectActionResponse = redirectAction(myOptions.submit_redirect_url, myOptions.submit_redirect_delay, ays_block_element, myOptions.submit_redirect_after, form, myOptions, true, uniqueCode);
1577                    }
1578                }
1579            }
1580        }else{
1581            if(response.showIntervalMessage && ( response.interval_redirect_url !== null && response.interval_redirect_url != '' )){
1582                redirectActionResponse = redirectAction(response.interval_redirect_url, response.interval_redirect_delay, ays_block_element, response.interval_redirect_after, form, myOptions, false, uniqueCode);
1583            }else{
1584                if (myOptions.redirect_after_submit && myOptions.redirect_after_submit == 'on') {
1585                    redirectActionResponse = redirectAction(myOptions.submit_redirect_url, myOptions.submit_redirect_delay, ays_block_element, myOptions.submit_redirect_after, form, myOptions, true, uniqueCode);
1586                }
1587            }
1588        }
1589
1590        if( redirectActionResponse === false ){
1591            return false;
1592        }
1593
1594        form.find('div.ays_message').css('display', 'none');
1595        form.find('.ays_average').css({'display': 'block'});
1596        var quizScore = '';
1597        switch(response.displayScore){
1598            case 'by_percentage':
1599                quizScore = parseInt(response.score);
1600            break;
1601            case 'by_correctness':
1602                quizScore = response.score.split('/');
1603            break;
1604            case 'by_points':
1605                quizScore = response.score.split('/');
1606            break;
1607            default:
1608                quizScore = parseInt(response.score);
1609        }
1610
1611        form.find('.ays_quiz_timer_container').slideUp(500);
1612
1613        if (response.hide_result) {
1614            form.find('div.ays_message').html(response.text);
1615        } else {
1616            if(response.showIntervalMessage){
1617                form.find('div.ays_message').html(response.intervalMessage + response.finishText);
1618                if (response.product) {
1619                   // var $wooBlock = $("<div class='ays-woo-block'></div>");
1620                   // var $wooInBlock = $("<div class='ays-woo-product-block'></div>");
1621                   // var $wooImage = $('<div class="product-image"><img src="' + response.product.image + '" alt="WooCommerce Product"></div>');
1622                   // var $wooName = $('<h4 class="ays-woo-product-title"><a href="'+response.product.prodUrl+'" target="_blank">'+response.product.name+'</a></h4>');
1623                   // var $wooCartLink = $(response.product.link);
1624                   // if(response.product.image){
1625                   //     $wooBlock.append($wooImage);
1626                   // }
1627                   // $wooInBlock.append($wooName);
1628                   // $wooInBlock.append($wooCartLink);
1629                   // $wooBlock.append($wooInBlock);
1630                   // form.find('div.ays_message').after($wooBlock);
1631                   // if(form.parents('.ays-quiz-container').width() < 420){
1632                   //     form.find('.ays-woo-block').css('flex-wrap', 'wrap');
1633                   //     if(response.product.image){
1634                   //         form.find('.ays-woo-product-block').css('padding-top', '20px');
1635                   //     }
1636                   // }
1637                    var $wooBlock = '';
1638                    var $wooInBlock = '';
1639                    var $wooImage = '';
1640                    var $wooName = '';
1641                    var $wooCartLink = '';
1642                    var $wooBloks = '';
1643                    $wooBloks = $("<div class='ays-woo-block-main'></div>")
1644                    for(var products in response.product){
1645                        $wooBlock    = $("<div class='ays-woo-block'></div>");
1646                        $wooInBlock  = $("<div class='ays-woo-product-block'></div>");
1647                        $wooImage    = $('<div class="product-image"><img src="' + response.product[products].image + '" alt="WooCommerce Product"></div>');
1648                        $wooName     = $('<h4 class="ays-woo-product-title"><a href="'+response.product[products].prodUrl+'" target="_blank">'+response.product[products].name+'</a></h4>');
1649                        $wooCartLink = $(response.product[products].link);
1650                        if(response.product[products].image){
1651                            $wooBlock.append($wooImage);
1652                        }
1653                        $wooBloks.append($wooBlock);
1654                        $wooInBlock.append($wooName);
1655                        $wooInBlock.append($wooCartLink);
1656                        $wooBlock.append($wooInBlock);
1657                        form.find('div.ays_message').after($wooBloks);
1658                        if(form.parents('.ays-quiz-container').width() < 420){
1659                            form.find('.ays-woo-block').css('flex-wrap', 'wrap');
1660                            if(response.product[products].image){
1661                                form.find('.ays-woo-product-block').css('padding-top', '20px');
1662                            }
1663                        }
1664                    }
1665                }
1666            }else{
1667                form.find('div.ays_message').html(response.finishText);
1668            }
1669
1670            if(conditionsExict){
1671                form.find('div.ays_message').prepend(conditionPageMessage);
1672            }
1673
1674            form.find('p.ays_score').removeClass('ays_score_display_none');
1675            form.find('p.ays_score').html(form.find('p.ays_score').text()+'<span class="ays_score_percent animated"> ' + response.score + '</span>');
1676        }
1677        
1678        if( response.socialHeading ){
1679            form.find(".ays-quiz-social-shares-heading").html(response.socialHeading);
1680        }
1681
1682        if( response.socialLinksHeading && response.socialLinksHeading != "" ){
1683            form.find(".ays-quiz-social-links-heading").html(response.socialLinksHeading);
1684        }
1685
1686        form.find('div.ays_message').fadeIn(500);
1687        setTimeout(function () {
1688            form.find('p.ays_score').addClass('tada');
1689        }, 500);
1690        var numberOfPercent = 0;
1691        var percentAnimate = setInterval(function(){
1692            if(typeof quizScore == 'number'){
1693                form.find('.ays-progress-value').text(numberOfPercent + "%");
1694                if(numberOfPercent == quizScore){
1695                    clearInterval(percentAnimate);
1696                }
1697                numberOfPercent++;
1698            }else{
1699                var total = quizScore[1];
1700                var count = quizScore[0];
1701                total = parseFloat(total.trim());
1702                count = parseFloat(count.trim());
1703                form.find('.ays-progress-value').text(numberOfPercent + " / " + total);
1704                if(numberOfPercent >= count){
1705                    form.find('.ays-progress-value').text(count + " / " + total);
1706                    clearInterval(percentAnimate);
1707                }
1708                numberOfPercent++;
1709            }
1710        },20);
1711        
1712        var score = quizScore;
1713        if(response.displayScore == 'by_correctness' || response.displayScore == 'by_points'){
1714            var total = parseInt(quizScore[1].trim());
1715            var count = parseInt(quizScore[0].trim());
1716            score = (count / total) * 100;
1717        }
1718
1719        if(response.scoreMessage){
1720            form.find('div.ays_score_message').html(response.scoreMessage);
1721        }
1722
1723        var last_result_id = null;
1724        if(response.result_id && response.result_id != ''){
1725            last_result_id = parseInt( response.result_id );
1726        }
1727
1728        aysQuizSetCustomEvent();
1729        var trackUsersEvent = new CustomEvent('getResultId', {
1730            detail: {
1731              resultId: last_result_id
1732            }
1733        });
1734        form.get(0).dispatchEvent(trackUsersEvent);
1735
1736        // Make responses anonymous
1737        myOptions.quiz_make_responses_anonymous = ( myOptions.quiz_make_responses_anonymous ) ? myOptions.quiz_make_responses_anonymous : 'off';
1738        var quiz_make_responses_anonymous = (myOptions.quiz_make_responses_anonymous && myOptions.quiz_make_responses_anonymous == "on") ? true : false;
1739
1740        // Enable Keyboard Navigation
1741        myOptions.quiz_enable_keyboard_navigation = ! myOptions.quiz_enable_keyboard_navigation ? 'off' : myOptions.quiz_enable_keyboard_navigation;
1742        var quiz_enable_keyboard_navigation = (myOptions.quiz_enable_keyboard_navigation && myOptions.quiz_enable_keyboard_navigation == 'on') ? true : false;
1743
1744        // Make responses anonymous
1745        myOptions.quiz_enable_user_cÕ°oosing_anonymous_assessment = ( myOptions.quiz_enable_user_cÕ°oosing_anonymous_assessment ) ? myOptions.quiz_enable_user_cÕ°oosing_anonymous_assessment : 'off';
1746        var quiz_enable_user_cÕ°oosing_anonymous_assessment = (myOptions.quiz_enable_user_cÕ°oosing_anonymous_assessment && myOptions.quiz_enable_user_cÕ°oosing_anonymous_assessment == "on") ? true : false;
1747
1748        // Show question results on the results page
1749        myOptions.enable_questions_result = ! myOptions.enable_questions_result ? 'off' : myOptions.enable_questions_result;
1750        var enable_questions_result = (myOptions.enable_questions_result && myOptions.enable_questions_result == 'on') ? true : false;
1751
1752        // Show/hide results based on pass score
1753        myOptions.quiz_show_results_based_pass_score = ! myOptions.quiz_show_results_based_pass_score ? 'off' : myOptions.quiz_show_results_based_pass_score;
1754        var quiz_show_results_based_pass_score = (myOptions.quiz_show_results_based_pass_score && myOptions.quiz_show_results_based_pass_score == 'on') ? true : false;
1755
1756        
1757        var showResultsPassScoreFlag = true;
1758        if(enable_questions_result && quiz_show_results_based_pass_score){
1759            showResultsPassScoreFlag = false;
1760            if(response.pass_score_flag){
1761                showResultsPassScoreFlag = true;
1762            }
1763        }
1764
1765        if( form.find('.ays-chart-container').length > 0 ){
1766            form.find('.ays-chart-container').AysChartBuilder();
1767        }
1768
1769        // DataTable function exists in jQuery
1770        if (typeof $.fn.DataTable !== 'undefined') {
1771            form.find('#ays-quiz-all-result-score-page, .ays-individual-quiz-all-result-score-page').DataTable({ 
1772                "destroy": true, //use for reinitialize datatable
1773            }); 
1774        }
1775
1776        var class_for_keyboard = '';
1777        var attributes_for_keyboard = '';
1778
1779        if( quiz_enable_keyboard_navigation ){
1780            class_for_keyboard = "ays-quiz-keyboard-active";
1781            attributes_for_keyboard = "tabindex='0'";
1782        }
1783
1784        if(score > 0){
1785            form.find('.ays-progress-bar').css('padding-right', '7px');
1786            var progressBarStyle = myOptions.progress_bar_style ? myOptions.progress_bar_style : 'first';
1787            if(progressBarStyle == 'first' || progressBarStyle == 'second'){
1788                form.find('.ays-progress-value').css('width', 0);
1789                form.find('.ays-progress-value').css('transition', 'width ' + score*25 + 'ms linear');
1790                setTimeout(function(){
1791                    form.find('.ays-progress-value').css('width', score+'%');
1792                }, 1);
1793            }
1794            form.find('.ays-progress-bar').css('transition', 'width ' + score*25 + 'ms linear');
1795            setTimeout(function(){
1796                form.find('.ays-progress-bar').css('width', score+'%');
1797            }, 1);
1798        }
1799
1800        if ( score == 0 ) {
1801            // Quiz background Color
1802            var quiz_make_bg_color = (myOptions.bg_color && myOptions.bg_color != "") ? myOptions.bg_color : '#fff';
1803
1804            form.find('.ays-progress-value').css('color', quiz_make_bg_color);
1805        }
1806
1807        form.append($("<div class='ays_quiz_results'></div>"));
1808        var formResults = form.find('.ays_quiz_results');
1809        if (form.hasClass('enable_questions_result') && showResultsPassScoreFlag) {
1810
1811            // Enable the Show/Hide toggle
1812            myOptions.quiz_enable_results_toggle = ! myOptions.quiz_enable_results_toggle ? 'off' : myOptions.quiz_enable_results_toggle;
1813            var quiz_enable_results_toggle = (myOptions.quiz_enable_results_toggle && myOptions.quiz_enable_results_toggle == 'on') ? true : false;
1814
1815            var resultToggleHTML = "";
1816
1817            resultToggleHTML += '<div class="ays-quiz-results-toggle-block">';
1818                resultToggleHTML += '<span class="ays-show-res-toggle ays-res-toggle-show">'+ quizLangObj.show +'</span>';
1819                resultToggleHTML += '<input type="checkbox" class="ays_toggle ays_toggle_slide ays-quiz-res-toggle-checkbox" id="ays-quiz-show-results-toggle-'+ quizId +'" checked>';
1820                resultToggleHTML += '<label for="ays-quiz-show-results-toggle-'+ quizId +'" class="ays_switch_toggle '+ class_for_keyboard +'" '+ attributes_for_keyboard +'>Toggle</label>';
1821                resultToggleHTML += '<span class="ays-show-res-toggle ays-res-toggle-hide quest-toggle-failed">'+ quizLangObj.hide +'</span>';
1822            resultToggleHTML += '</div>';
1823
1824            if ( quiz_enable_results_toggle ) {
1825                formResults.append(resultToggleHTML);
1826            }
1827
1828            var questions = form.find('div[data-question-id]');
1829            var showOnlyWrongAnswer = (myOptions.show_only_wrong_answer && myOptions.show_only_wrong_answer == "on") ? true : false;
1830            if(myOptions.enable_correction && myOptions.enable_correction != 'on'){
1831                showOnlyWrongAnswer = false;
1832            }
1833
1834            var ans_right_wrong_icon = (myOptions.ans_right_wrong_icon && myOptions.ans_right_wrong_icon != "") ? myOptions.ans_right_wrong_icon : "default";
1835
1836            var correct_img_URL = "";
1837            var wrong_img_URL   = "";
1838            if( ans_right_wrong_icon == "default"){
1839                correct_img_URL = quiz_maker_ajax_public.AYS_QUIZ_PUBLIC_URL + "/images/correct.png";
1840                wrong_img_URL   = quiz_maker_ajax_public.AYS_QUIZ_PUBLIC_URL + "/images/wrong.png";
1841            } else if( ans_right_wrong_icon == "none" ){
1842                correct_img_URL = "";
1843                wrong_img_URL   = "";
1844            } else {
1845                correct_img_URL = quiz_maker_ajax_public.AYS_QUIZ_PUBLIC_URL + "/images/correct-"+ ans_right_wrong_icon +".png";
1846                wrong_img_URL   = quiz_maker_ajax_public.AYS_QUIZ_PUBLIC_URL + "/images/wrong-"+ ans_right_wrong_icon +".png";
1847            }
1848
1849            var correct_img_URL_HTML = "";
1850            var wrong_img_URL_HTML   = "";
1851            if (correct_img_URL != "") {
1852                correct_img_URL_HTML = "<img class='ays-quiz-check-button-right-wrong-icon' data-type='"+ans_right_wrong_icon+"' src='"+ correct_img_URL +"'>";
1853            }
1854
1855            if (wrong_img_URL != "") {
1856                wrong_img_URL_HTML = "<img class='ays-quiz-check-button-right-wrong-icon' data-type='"+ ans_right_wrong_icon +"' src='"+ wrong_img_URL +"'>";
1857            }
1858
1859            // Strong calculation of answers score
1860            myOptions.checkbox_score_by = ( myOptions.checkbox_score_by ) ? myOptions.checkbox_score_by : 'off';
1861            var checkbox_score_by = (myOptions.checkbox_score_by && myOptions.checkbox_score_by == "on") ? true : false;
1862
1863            // Strong calculation of answers score
1864            myOptions.quiz_hide_banner_questions_on_result_page = ( myOptions.quiz_hide_banner_questions_on_result_page ) ? myOptions.quiz_hide_banner_questions_on_result_page : 'off';
1865            var quiz_hide_banner_questions_on_result_page = (myOptions.quiz_hide_banner_questions_on_result_page && myOptions.quiz_hide_banner_questions_on_result_page == "on") ? true : false;
1866
1867            var answerIsRightArr = new Array();
1868            for (var z = 0; z < questions.length; z++) {                
1869                if(questions.eq(z).hasClass('not_influence_to_score')){
1870                    continue;
1871                }
1872
1873                questions.eq(z).find('.ays_buttons_div').remove();
1874
1875                if( questions.eq(z).hasClass('ays-has-error') ){
1876                    questions.eq(z).removeClass('ays-has-error');
1877                }
1878
1879                var question = questions.eq(z).clone(true, true);
1880                var questionId = question.attr('data-question-id');
1881                var questionType = question.attr('data-type');
1882                var question_original_html = questions.eq(z).find('.ays_quiz_question');
1883                var question_original_html_clone = question_original_html.clone(true, true);
1884
1885                if( quiz_hide_banner_questions_on_result_page && questionType == 'custom' ){
1886                    continue;
1887                }
1888
1889
1890                var ays_quiz_question_html      = questions.eq(z).find('.ays_quiz_question');
1891                var ays_quiz_question_img_html  = questions.eq(z).find('.ays-image-question-img');
1892                var question_explanation_html   = questions.eq(z).find('.ays_questtion_explanation');
1893                var wrong_answer_text_html      = questions.eq(z).find('.wrong_answer_text');
1894                var right_answer_text_html      = questions.eq(z).find('.right_answer_text');
1895                var question_report_html        = questions.eq(z).find('.ays_question_report');
1896                var note_message_box_html       = questions.eq(z).find('.ays-quiz-question-note-message-box');
1897                var text_to_speech_html         = questions.eq(z).find('.ays-quiz-question-title-text-to-speech-icon');
1898
1899                var question_parts_arr = new Array(
1900                    text_to_speech_html,
1901                    note_message_box_html,
1902                    question_explanation_html,
1903                    wrong_answer_text_html,
1904                    right_answer_text_html,
1905                    question_report_html,
1906                );
1907
1908                question.find('.ays_quiz_question').remove();
1909                question.find('.ays-abs-fs').prepend( questions.eq(z).find('.ays_quiz_question') );
1910
1911                question.find('.ays_questtion_explanation').remove();
1912                question.find('.ays-abs-fs').append( questions.eq(z).find('.ays_questtion_explanation') );
1913
1914                question.find('.wrong_answer_text').remove();
1915                question.find('.ays-abs-fs').append( questions.eq(z).find('.wrong_answer_text') );
1916
1917                question.find('.right_answer_text').remove();
1918                question.find('.ays-abs-fs').append( questions.eq(z).find('.right_answer_text') );
1919
1920                question.find('input[type="button"]').remove();
1921                question.find('input[type="submit"]').remove();
1922                question.find('.ays_arrow').remove();
1923                question.find('.ays-export-quiz-button-container').remove();
1924                question.find('.ays-quiz-questions-nav-bookmark-box').remove();
1925
1926                question.find('.ays-quiz-category-description-box').addClass('ays_display_none');
1927
1928                question.addClass('ays_question_result');
1929                var checked_inputs = question.find('input:checked');
1930                var un_checked_inputs = question.find('input:checkbox:not(:checked)');
1931                var text_answer = question.find('textarea.ays-text-input');
1932                var number_answer = question.find('input[type="number"].ays-text-input');
1933                var short_text_answer = question.find('input[type="text"].ays-text-input:not(.ays-quiz-fill-in-blank-input)');
1934                var fillInBlankAnswers = question.find('div.ays_quiz_question input[type="text"].ays-text-input.ays-quiz-fill-in-blank-input');
1935                var date_answer = question.find('input[type="date"].ays-text-input');
1936                var selected_options = question.find('select');
1937                var answerIsRight = false;
1938
1939                var fieldset_html = "<fieldset class='ays_fieldset'>" + "<legend>" + quizLangObj.notAnsweredText + "</legend>" + "</fieldset>";
1940                var question_html = question.find('.ays-abs-fs > *:not(.ays_quiz_question)').clone(true, true);
1941
1942                myOptions.hide_correct_answers = (myOptions.hide_correct_answers) ? myOptions.hide_correct_answers : 'off';
1943                var hideRightAnswers =(myOptions.hide_correct_answers && myOptions.hide_correct_answers == 'on') ? true : false;
1944
1945                if( questionType == "radio" || questionType == "checkbox"){
1946                    var parentStep = question;
1947                    var questionID = questionId;
1948                    var radioInputData = question.find('.ays-quiz-answers .ays-field input[name*="ays_questions"]');
1949
1950                    for (var i = 0; i < radioInputData.length; i++) {
1951                        var currentAnswer = $( radioInputData[i] );
1952                        var currentAnswerID = currentAnswer.val();
1953                        
1954                        if( typeof questionID != "undefined" && questionID !== null ){
1955
1956                            var thisQuestionCorrectAnswer = myQuizOptions[questionID].question_answer.length <= 0 ? array() : myQuizOptions[questionID].question_answer;
1957                            var ifCorrectAnswer = thisQuestionCorrectAnswer[currentAnswerID] == '' ? '' : thisQuestionCorrectAnswer[currentAnswerID];
1958                            if( typeof ifCorrectAnswer != "undefined" ){
1959                                question.find('input[name="ays_answer_correct[]"]').val(ifCorrectAnswer);
1960
1961                                for (var question_answer_ID in thisQuestionCorrectAnswer) {
1962                                    var UserAnswered_true_or_false = thisQuestionCorrectAnswer[question_answer_ID];
1963                                    question.find('.ays-quiz-answers .ays-field input[value="'+ question_answer_ID +'"]').prev().val(UserAnswered_true_or_false);
1964                                }
1965                            }
1966                        }
1967                    }
1968                }
1969                
1970                if(showOnlyWrongAnswer === false){
1971                    question.find('input[name="ays_answer_correct[]"][value="1"]').parent().find('label').addClass('correct answered');
1972                    question.find('input[name="ays_answer_correct[]"][value="1"]').parents('div.ays-field').addClass('correct_div');
1973                }
1974
1975                if(checked_inputs.length === 0){
1976                    var emptyAnswer = false;
1977                    if(question.find('input[type="radio"]').length !== 0){
1978                        emptyAnswer = true;
1979                    }
1980                    if(question.find('input[type="checkbox"]').length !== 0){
1981                        emptyAnswer = true;
1982                    }
1983                    if(emptyAnswer){
1984
1985                        var q_answer_text_html = question.find('.ays-abs-fs .ays-quiz-answers');
1986                        question.find('.ays-abs-fs').html(fieldset_html);
1987                        question.find('.ays-abs-fs .ays_fieldset').append(ays_quiz_question_html);
1988                        question.find('.ays-abs-fs .ays_fieldset').append(ays_quiz_question_img_html);
1989                        question.find('.ays-abs-fs .ays_fieldset').append(q_answer_text_html );
1990
1991                        for (var i = 0; i < question_parts_arr.length; i++) {
1992                            question.find('.ays-abs-fs .ays_fieldset').append( question_parts_arr[i] );
1993                        }
1994
1995                        question.find('.ays-abs-fs').css({
1996                            'padding': '7px',
1997                            // 'width': '100%'
1998                        });
1999                    }
2000                }
2001
2002                var aysAudio = $(document).find('.ays_question_result audio');
2003                if(aysAudio.length > 0){
2004                    aysAudio.each(function(e, el){
2005                        el.pause();
2006                    });
2007                }
2008
2009                selected_options.each(function(element, item){
2010                    var questionType = $(item).parents('.step').attr('data-type');
2011                    var selectOptions = $(item).children("option[data-chisht]");
2012                    var selectedOption = $(item).children("option[data-chisht]:selected");
2013                    var answerClass, answerDivClass, attrChecked, answerClassForSelected, answerClass_tpel, answerViewClass, attrCheckedStyle = "", attrCheckedStyle2;
2014                    var prefixIcon = '', attrCheckedStyle3 = '', attrCheckedStyle4;
2015                    var correctAnswersDiv = '', rectAnswerBefore = "";
2016
2017                    var matchingSelectedOptionsCount = null;
2018                    if ( $(item).parents('.step').data('type') === 'matching' ) {
2019                        selectOptions = $(item).children("option");
2020                        selectedOption = $(item).children("option[selected]:selected");
2021
2022                        var matchingSelectElements = $(item).parents('.step').find('select');
2023                        var matchingSelectCount = matchingSelectElements.length;
2024                        var matchingSelectedOptions = matchingSelectElements.find('option[selected]:selected');
2025                        var matchingSelectedOptionsCount = matchingSelectedOptions.length;
2026
2027                        if( window.aysMatchingAnsweredOptionCount === null ){
2028                            window.aysMatchingAnsweredOptionCount = matchingSelectedOptionsCount;
2029                        }
2030
2031                        var matchingEmptyFlag = true;
2032                    }
2033
2034                    // var answerViewClassVal = form.find('.answer_view_class').val();
2035                    var answerViewClassVal = 'list';
2036
2037                    if(questionType == 'matching'){
2038                        answerViewClassVal = 'list';
2039                    }
2040
2041                    answerViewClass = "ays_"+answerViewClassVal+"_view_item";
2042                    var isAnswerCorrectFlag = true;
2043                    for(var j = 0; j < selectOptions.length; j++){
2044                        if($(selectOptions[j]).attr("value") == '' || $(selectOptions[j]).attr("value") == undefined || $(selectOptions[j]).attr("value") == null){
2045                            continue;
2046                        }
2047
2048                        if($(selectOptions[j]).attr("data-nkar") == '' || $(selectOptions[j]).attr("data-nkar") == undefined || $(selectOptions[j]).attr("data-nkar") == null){
2049                            var selectedOptionImageHTML = "";
2050                        } else {
2051                            var selectedOptionImageURL = $(selectOptions[j]).attr("data-nkar");
2052                            var selectedOptionImageHTML = '<img src="'+ selectedOptionImageURL +'" alt="" class="ays-answer-image" />';
2053                        }
2054
2055                        var isAnswerCorrect = parseInt($(selectOptions[j]).data("chisht")) === 1;
2056                        if ( $(item).parents('.step').data('type') === 'matching' ) {
2057                            var answerId = $(item).parents('.ays-matching-field-match').data('answerId');
2058                            var thisAnswerOptions = myQuizOptions[questionId];
2059                            var choice = thisAnswerOptions.question_answer[ $(selectOptions[j]).attr("value") ];
2060                            isAnswerCorrect = Number( answerId ) === Number( choice );
2061                            
2062                            if( hideRightAnswers && selectedOption.length == 0 && isA
2062nswerCorrectFlag ) {
2063                                correctAnswersDiv += '<div class="ays-field-matching-type-empty-answer">' +
2064                                '<span>'+ quizLangObj.unansweredQuestion +'</span> ' +
2065                            '</div>';
2066                                isAnswerCorrectFlag = false;
2067                                continue;
2068                            }else if( isAnswerCorrect && hideRightAnswers && $(selectOptions[j]).prop('selected') == false ) {
2069                                continue;
2070                            }
2071                        }
2072
2073                        if($(selectOptions[j]).prop('selected') == true){
2074                            if(isAnswerCorrect){
2075                                answerClassForSelected = " correct answered ";
2076                                answerDivClass = "correct_div checked_answer_div";
2077                                attrChecked = "checked='checked'";
2078                                answerIsRight = true;
2079                            }else{
2080                                answerClassForSelected = " wrong answered ";
2081                                attrChecked = "checked='checked'";
2082                                answerDivClass = "wrong_div checked_answer_div ";
2083                            }
2084                        }else{
2085                            if(showOnlyWrongAnswer === false){
2086                                if(isAnswerCorrect){
2087                                    answerClassForSelected = " correct answered ";
2088                                    answerDivClass = "correct_div checked_answer_div";
2089                                    attrChecked = "";
2090                                }else{
2091                                    answerClassForSelected = "";
2092                                    attrChecked = "";
2093                                    answerDivClass = "";
2094                                }
2095                            }else{
2096                                answerClassForSelected = "";
2097                                attrChecked = "";
2098                                answerDivClass = "";
2099                            }
2100                        }
2101                        attrCheckedStyle2 = "style='padding:0 !important;'";
2102                        if(form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
2103                           form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
2104                            if($(selectOptions[j]).prop('selected') == true){
2105                                if(isAnswerCorrect){
2106                                    prefixIcon = '<i class="ays_fa answer-icon ays_fa_check_square_o"></i>';
2107                                    attrCheckedStyle3 = "";
2108                                }else{                                                        
2109                                    prefixIcon = '<i class="ays_fa answer-icon ays_fa_check_square_o"></i>';
2110                                    attrCheckedStyle3 = "background-color: rgba(243,134,129,0.8);";
2111                                }
2112                            }else{
2113                                if(showOnlyWrongAnswer === false){
2114                                    if(isAnswerCorrect){
2115                                        prefixIcon = '<i class="ays_fa answer-icon ays_fa_square_o"></i>';
2116                                        attrCheckedStyle3 = "";
2117                                    }else{
2118                                        prefixIcon = '<i class="ays_fa answer-icon ays_fa_square_o"></i>';
2119                                        attrCheckedStyle3 = "";
2120                                    }
2121                                }else{
2122                                    prefixIcon = '<i class="ays_fa answer-icon ays_fa_square_o"></i>';
2123                                    attrCheckedStyle3 = "";
2124                                }
2125                            }
2126                                attrCheckedStyle = "style='display:block!important;"+attrCheckedStyle3+"'";
2127                                attrCheckedStyle2 = "";
2128                                answerViewClass = "";
2129                           }
2130                        if(form.parents('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') ||
2131                           form.parents('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){
2132                            if($(selectOptions[j]).prop('selected') == true){
2133                                if(isAnswerCorrect){
2134                                    answerDivClass = "correct_div checked_answer_div";
2135                                    attrCheckedStyle = "style='padding: 0!important;'";
2136                                }else{
2137                                    answerDivClass = "wrong_div checked_answer_div";
2138                                    attrCheckedStyle = "style='padding: 0!important;'";
2139                                }
2140                            }else{
2141                                if(showOnlyWrongAnswer === false){
2142                                    if(isAnswerCorrect){
2143                                        answerDivClass = "correct_div checked_answer_div";
2144                                    }else{
2145                                        answerDivClass = "";
2146                                    }
2147                                }else{
2148                                    answerDivClass = "";
2149                                }
2150                                attrCheckedStyle = "";
2151                            }
2152                        }
2153                        if(form.parents('.ays-quiz-container').hasClass('ays_quiz_rect_dark') ||
2154                           form.parents('.ays-quiz-container').hasClass('ays_quiz_rect_light')){
2155                            if($(selectOptions[j]).prop('selected') == true){
2156                                if(isAnswerCorrect){
2157                                    answerDivClass = "correct_div checked_answer_div";
2158                                }else{
2159                                    answerDivClass = "wrong_div checked_answer_div";
2160                                }
2161                                rectAnswerBefore = "rect_answer_correct_before";
2162                            }else{
2163                                if(showOnlyWrongAnswer === false){
2164                                    if(isAnswerCorrect){
2165                                        answerDivClass = "correct_div checked_answer_div";
2166                                    }else{
2167                                        answerDivClass = "";
2168                                    }
2169                                }else{
2170                                    answerDivClass = "";
2171                                }
2172                                rectAnswerBefore = "rect_answer_wrong_before";
2173                            }
2174                        }
2175                        
2176                        if( answerDivClass == "" && questionType == 'matching' ){
2177                            continue;
2178                        } 
2179                        
2180                        correctAnswersDiv += '<div class="ays-field '+answerViewClass+' '+answerDivClass+'" '+attrCheckedStyle+'>' +
2181                                '<input type="radio" value="'+$(selectOptions[j]).attr("value")+'" name="'+$(item).parent().find('.ays-select-field-value').attr('name')+'" disabled="disabled" '+attrChecked+'>' +
2182                                '<label class="'+answerClassForSelected+'" for="ays-answer-'+$(selectOptions[j]).attr("value")+'">'+prefixIcon+aysEscapeHtml($(selectOptions[j]).text())+'</label> ' +
2183                                '<label for="ays-answer-'+$(selectOptions[j]).attr("value")+'" class="ays_answer_image ays_empty_before_content '+answerClassForSelected+'">'+ selectedOptionImageHTML +'</label>' +
2184                            '</div>';
2185                    }
2186
2187                    if ( $(item).parents('.step').data('type') === 'matching' ) {
2188                        $(item).parents('.ays-abs-fs').parent().find('.ays-text-right-answer').remove();
2189                        $(item).parents('.ays-abs-fs').parent().find('.select2-container').remove();
2190                        $(item).parents('.ays-matching-field-match').append(correctAnswersDiv);
2191                    } else {
2192                        $(item).parent().parent().find('.ays-text-right-answer').remove();
2193                        $(item).parent().parent().append(correctAnswersDiv);
2194                        $(item).parent().hide();
2195                    }
2196
2197                    if(selectedOption.length === 0 && questionType != 'matching' ){
2198                        var _parent_item = $(item).parents('.ays-abs-fs');
2199
2200                        _parent_item.html(fieldset_html);
2201                        _parent_item.find('.ays_fieldset').append(ays_quiz_question_html);
2202                        _parent_item.find('.ays_fieldset').append(ays_quiz_question_img_html);
2203                        _parent_item.find('.ays_fieldset').append($(item).parents('.ays-quiz-answers'));
2204
2205                        for (var i = 0; i < question_parts_arr.length; i++) {
2206                            _parent_item.find('.ays_fieldset').append( question_parts_arr[i] );
2207                        }
2208
2209                        $(item).parents('.ays-abs-fs').css({
2210                            'padding': '7px'
2211                        });
2212                    } else if( questionType == 'matching' && window.aysMatchingAnsweredOptionCount === 0){
2213                        var _parent_item = $(item).parents('.ays-abs-fs');
2214                        _parent_item.html(fieldset_html);
2215                        _parent_item.find('.ays_fieldset').append(ays_quiz_question_html);
2216                        _parent_item.find('.ays_fieldset').append(ays_quiz_question_img_html);
2217                        _parent_item.find('.ays_fieldset').append($(item).parents('.ays-quiz-answers'));
2218
2219                        for (var i = 0; i < question_parts_arr.length; i++) {
2220                            _parent_item.find('.ays_fieldset').append( question_parts_arr[i] );
2221                        }
2222
2223                        $(item).parents('.ays-abs-fs').css({
2224                            'padding': '7px'
2225                        });
2226                        window.aysMatchingAnsweredOptionCount = null;
2227                    }
2228
2229
2230
2231                    $(item).parents('.ays-abs-fs').find('.ays_buttons_div').remove();
2232                    if ( $(item).parents('.step').data('type') === 'matching' ) {
2233                        $(item).parent().find('.select2.select2-container').remove();
2234                        $(item).remove();
2235                    } else {
2236                        $(item).parent().remove();
2237                    }
2238                });
2239
2240                if( questionType == "matching" ){
2241                    var correctChoicesCount = question.find('.ays-quiz-answers .ays-matching-field .ays-field.ays-matching-field-option.correct_div').length;
2242                    var wrongChoicesCount = question.find('.ays-quiz-answers .ays-matching-field .ays-field.ays-matching-field-option.wrong_div').length;
2243
2244                    if(checkbox_score_by){
2245                        if ( wrongChoicesCount > 0 ) {
2246                            question.find('.wrong_answer_text').slideDown(500);
2247                            question.find('.right_answer_text').addClass('ays_display_none');
2248                        } else {
2249                            question.find('.right_answer_text').slideDown(500);
2250                            question.find('.wrong_answer_text').addClass('ays_display_none');
2251                        }
2252                    } else {
2253                        if ( correctChoicesCount > wrongChoicesCount ) {
2254                            question.find('.right_answer_text').slideDown(500);
2255                            question.find('.wrong_answer_text').addClass('ays_display_none');
2256                        } else {
2257                            question.find('.wrong_answer_text').slideDown(500);
2258                            question.find('.right_answer_text').addClass('ays_display_none');
2259                        }
2260                    }
2261                }
2262                
2263                text_answer.next().next().remove();
2264                text_answer.css('width', '100%');
2265                text_answer.attr('disabled', 'disabled');
2266                number_answer.next().next().remove();
2267                number_answer.css('width', '100%');
2268                number_answer.attr('disabled', 'disabled');
2269                short_text_answer.next().next().remove();
2270                short_text_answer.css('width', '100%');
2271                short_text_answer.attr('disabled', 'disabled');
2272                // fillInBlankAnswers.next().next().remove();
2273                // fillInBlankAnswers.attr('disabled', 'disabled');
2274                date_answer.next().next().remove();
2275                date_answer.css('width', '100%');
2276                date_answer.attr('disabled', 'disabled');
2277                if(text_answer.val() == ''){
2278                    if(showOnlyWrongAnswer === false){
2279                        var rightAnswerText = '<div class="ays-text-right-answer">';
2280                        var thisQuestionAnswer = text_answer.attr('chishtpatasxan');
2281                        if(typeof thisQuestionAnswer != 'undefined'){
2282                            thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
2283                            thisQuestionAnswer = thisQuestionAnswer.split('%%%');
2284                        }else{
2285                            thisQuestionAnswer = [''];
2286                        }
2287                        rightAnswerText += thisQuestionAnswer[0].trim();
2288
2289                        rightAnswerText += '</div>';
2290                        if(text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2291                            text_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2292                        }
2293                        text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2294                            'display': 'block'
2295                        });
2296                    }
2297                    text_answer.css('background-color', 'rgba(243,134,129,0.4)');
2298                    text_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
2299
2300                    if (wrong_img_URL_HTML != "") {
2301                        var if_img_exists = text_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2302                        if ( if_img_exists.length <= 0 ) {
2303                            text_answer.parent().append(wrong_img_URL_HTML);
2304                        }
2305                    }
2306
2307                    var _text_answer_parent = text_answer.parents('.ays-abs-fs');
2308
2309                    _text_answer_parent.html(fieldset_html);
2310                    _text_answer_parent.find('.ays_fieldset').append(ays_quiz_question_html);
2311                    _text_answer_parent.find('.ays_fieldset').append(ays_quiz_question_img_html);
2312                    _text_answer_parent.find('.ays_fieldset').append(text_answer.parents('.ays-quiz-answers'));
2313
2314                    for (var i = 0; i < question_parts_arr.length; i++) {
2315                        _text_answer_parent.find('.ays_fieldset').append( question_parts_arr[i] );
2316                    }
2317
2318                    text_answer.parents('.ays-abs-fs').css({
2319                        'padding': '7px'
2320                    });
2321                }else{
2322                    if(parseInt(text_answer.next().val()) == 1){
2323                        text_answer.css('background-color', 'rgba(39,174,96,0.5)');
2324                        answerIsRight = true;
2325
2326                        if (correct_img_URL_HTML != "") {
2327                            var if_img_exists = text_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2328                            if ( if_img_exists.length <= 0 ) {
2329                                text_answer.parent().append(correct_img_URL_HTML);
2330                            }
2331                        }
2332
2333                    }else{
2334                        text_answer.css('background-color', 'rgba(243,134,129,0.4)');
2335
2336                        if (wrong_img_URL_HTML != "") {
2337                            var if_img_exists = text_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2338                            if ( if_img_exists.length <= 0 ) {
2339                                text_answer.parent().append(wrong_img_URL_HTML);
2340                            }
2341                        }
2342
2343                        if(showOnlyWrongAnswer === false){
2344                            var rightAnswerText = '<div class="ays-text-right-answer">';
2345                            var thisQuestionAnswer = text_answer.attr('chishtpatasxan');
2346                            if(typeof thisQuestionAnswer != 'undefined'){
2347                                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
2348                                thisQuestionAnswer = thisQuestionAnswer.split('%%%');
2349                            }else{
2350                                thisQuestionAnswer = [''];
2351                            }
2352                            rightAnswerText += thisQuestionAnswer[0].trim();
2353
2354                            rightAnswerText += '</div>';
2355                            if(text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2356                                text_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2357                            }
2358                            text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2359                                'display': 'block'
2360                            });
2361                            text_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
2362                        }
2363                    }
2364                }
2365                if(number_answer.val() == ''){
2366                    if(showOnlyWrongAnswer === false){
2367                        var rightAnswerText = '<div class="ays-text-right-answer">'+
2368                            number_answer.attr('chishtpatasxan')+
2369                        '</div>';
2370                        if(number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2371                            number_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2372                        }
2373                        number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2374                            'display': 'block'
2375                        });
2376                    }
2377                    number_answer.css('background-color', 'rgba(243,134,129,0.8)');
2378                    number_answer.parents('.ays-abs-fs').find('.ays-quiz-number-error-message').addClass('ays_display_none');
2379
2380                    if (wrong_img_URL_HTML != "") {
2381                        var if_img_exists = number_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2382                        if ( if_img_exists.length <= 0 ) {
2383                            number_answer.parent().append(wrong_img_URL_HTML);
2384                        }
2385                    }
2386
2387                    var _number_answer_parent = number_answer.parents('.ays-abs-fs');
2388
2389                    _number_answer_parent.html(fieldset_html);
2390                    _number_answer_parent.find('.ays_fieldset').append(ays_quiz_question_html);
2391                    _number_answer_parent.find('.ays_fieldset').append(ays_quiz_question_img_html);
2392                    _number_answer_parent.find('.ays_fieldset').append(number_answer.parents('.ays-quiz-answers'));
2393                    
2394                    for (var i = 0; i < question_parts_arr.length; i++) {
2395                        _number_answer_parent.find('.ays_fieldset').append( question_parts_arr[i] );
2396                    }
2397
2398                    number_answer.parents('.ays-abs-fs').css({
2399                        'padding': '7px'
2400                    });
2401                }else{
2402                    if(parseInt(number_answer.next().val()) == 1){
2403                        number_answer.css('background-color', 'rgba(39,174,96,0.5)');
2404                        answerIsRight = true;
2405
2406                        if (correct_img_URL_HTML != "") {
2407                            var if_img_exists = number_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2408                            if ( if_img_exists.length <= 0 ) {
2409                                number_answer.parent().append(correct_img_URL_HTML);
2410                            }
2411                        }
2412
2413                    }else{
2414                        number_answer.css('background-color', 'rgba(243,134,129,0.4)');
2415
2416                        if (wrong_img_URL_HTML != "") {
2417                            var if_img_exists = number_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2418                            if ( if_img_exists.length <= 0 ) {
2419                                number_answer.parent().append(wrong_img_URL_HTML);
2420                            }
2421                        }
2422
2423                        if(showOnlyWrongAnswer === false){
2424                            var rightAnswerText = '<div class="ays-text-right-answer">'+
2425                                number_answer.attr('chishtpatasxan')+
2426                                '</div>';
2427                            if(number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2428                                number_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2429                            }
2430                            number_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2431                                'display': 'block'
2432                            });
2433                            number_answer.parents('.ays-abs-fs').find('.ays-quiz-number-error-message').addClass('ays_display_none');
2434                        }
2435                    }
2436                }
2437                if(short_text_answer.val() == ''){
2438                    if(showOnlyWrongAnswer === false){
2439                        var rightAnswerText = '<div class="ays-text-right-answer">';
2440                        var thisQuestionAnswer = short_text_answer.attr('chishtpatasxan');
2441                        if(typeof thisQuestionAnswer != 'undefined'){
2442                            thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
2443                            thisQuestionAnswer = thisQuestionAnswer.split('%%%');
2444                        }else{
2445                            thisQuestionAnswer = [''];
2446                        }
2447                        rightAnswerText += thisQuestionAnswer[0].trim();
2448
2449                        rightAnswerText += '</div>';
2450                        if(short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2451                            short_text_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2452                        }
2453                        short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2454                            'display': 'block'
2455       
2455                 });
2456                    }
2457                    short_text_answer.css('background-color', 'rgba(243,134,129,0.8)');
2458                    short_text_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
2459
2460                    if (wrong_img_URL_HTML != "") {
2461                        var if_img_exists = short_text_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2462                        if ( if_img_exists.length <= 0 ) {
2463                            short_text_answer.parent().append(wrong_img_URL_HTML);
2464                        }
2465                    }
2466
2467                    var _short_text_parent = short_text_answer.parents('.ays-abs-fs');
2468
2469                    _short_text_parent.html(fieldset_html);
2470                    _short_text_parent.find('.ays_fieldset').append(ays_quiz_question_html);
2471                    _short_text_parent.find('.ays_fieldset').append(ays_quiz_question_img_html);
2472                    _short_text_parent.find('.ays_fieldset').append(short_text_answer.parents('.ays-quiz-answers'));
2473                    
2474                    for (var i = 0; i < question_parts_arr.length; i++) {
2475                        _short_text_parent.find('.ays_fieldset').append( question_parts_arr[i] );
2476                    }
2477
2478                    short_text_answer.parents('.ays-abs-fs').css({
2479                        'padding': '7px'
2480                    });
2481                }else{
2482                    if(parseInt(short_text_answer.next().val()) == 1){
2483                        short_text_answer.css('background-color', 'rgba(39,174,96,0.5)');
2484                        answerIsRight = true;
2485
2486                        if (correct_img_URL_HTML != "") {
2487                            var if_img_exists = short_text_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2488                            if ( if_img_exists.length <= 0 ) {
2489                                short_text_answer.parent().append(correct_img_URL_HTML);
2490                            }
2491                        }
2492
2493                    }else{
2494                        short_text_answer.css('background-color', 'rgba(243,134,129,0.4)');
2495
2496                        if (wrong_img_URL_HTML != "") {
2497                            var if_img_exists = short_text_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2498                            if ( if_img_exists.length <= 0 ) {
2499                                short_text_answer.parent().append(wrong_img_URL_HTML);
2500                            }
2501                        }
2502
2503                        if(showOnlyWrongAnswer === false){
2504                            var rightAnswerText = '<div class="ays-text-right-answer">';
2505                            var thisQuestionAnswer = short_text_answer.attr('chishtpatasxan');
2506                            if(typeof thisQuestionAnswer != 'undefined'){
2507                                thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
2508                                thisQuestionAnswer = thisQuestionAnswer.split('%%%');
2509                            }else{
2510                                thisQuestionAnswer = [''];
2511                            }
2512                            rightAnswerText += thisQuestionAnswer[0].trim();
2513
2514                            rightAnswerText += '</div>';
2515                            if(short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2516                                short_text_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2517                            }
2518                            short_text_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2519                                'display': 'block'
2520                            });
2521                            short_text_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
2522                        }
2523                    }
2524                }
2525                if( fillInBlankAnswers.length > 0 ){
2526                    var if_fill_in_blank_empty = false;
2527                    var fill_in_blank_empty_arr = new Array();
2528                    var is_user_answer_correct = true;
2529                    var fillInBlankAnswers_last = false;
2530                    for (var i = 0; i < fillInBlankAnswers.length; i++) {
2531                        var fill_in_blank_answer = $( fillInBlankAnswers[i] );
2532                        // fill_in_blank_answer.next().remove();
2533                        // fill_in_blank_answer.next().next().remove();
2534                        fill_in_blank_answer.attr('disabled', 'disabled');
2535                        var fillInBlankAnswers_last = false;
2536                        if( (fillInBlankAnswers.length - 1) == i ){
2537                            var fillInBlankAnswers_last = true;
2538                        }
2539
2540                        if( fill_in_blank_answer.val() == '' ){
2541                            fill_in_blank_empty_arr.push('empty');
2542                        }
2543
2544                        if( fill_in_blank_empty_arr.length == fillInBlankAnswers.length ){
2545                            if_fill_in_blank_empty = true;
2546                        }
2547
2548                        if(if_fill_in_blank_empty && fillInBlankAnswers_last){
2549                            if(showOnlyWrongAnswer === false){
2550                                // var rightAnswerText = '<div class="ays-text-right-answer">';
2551                                // var thisQuestionAnswer = fill_in_blank_answer.attr('chishtpatasxan');
2552                                // if(typeof thisQuestionAnswer != 'undefined'){
2553                                //     thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
2554                                //     thisQuestionAnswer = thisQuestionAnswer.split('%%%');
2555                                // }else{
2556                                //     thisQuestionAnswer = [''];
2557                                // }
2558                                // rightAnswerText += thisQuestionAnswer[0].trim();
2559
2560                                // rightAnswerText += '</div>';
2561                                // if(fill_in_blank_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2562                                //     fill_in_blank_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2563                                // }
2564                                // fill_in_blank_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2565                                //     'display': 'block'
2566                                // });
2567                            }
2568                            fill_in_blank_answer.css('background-color', 'rgba(243,134,129,0.4)');
2569                            fill_in_blank_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
2570
2571                            if (wrong_img_URL_HTML != "") {
2572                                var if_img_exists = fill_in_blank_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2573                                if ( if_img_exists.length <= 0 ) {
2574                                    fill_in_blank_answer.parent().append(wrong_img_URL_HTML);
2575                                }
2576                            }
2577
2578                            var _fill_in_blank_answer_parent = fill_in_blank_answer.parents('.ays-abs-fs');
2579
2580                            _fill_in_blank_answer_parent.html(fieldset_html);
2581                            _fill_in_blank_answer_parent.find('.ays_fieldset').append(ays_quiz_question_html);
2582                            // _fill_in_blank_answer_parent.find('.ays_fieldset').append(fill_in_blank_answer);
2583                            _fill_in_blank_answer_parent.find('.ays_fieldset').append(ays_quiz_question_img_html);
2584                            // _fill_in_blank_answer_parent.find('.ays_fieldset').append(fill_in_blank_answer.parents('.ays-quiz-answers'));
2585                            
2586                            for (var j = 0; j < question_parts_arr.length; j++) {
2587                                _fill_in_blank_answer_parent.find('.ays_fieldset').append( question_parts_arr[j] );
2588                            }
2589
2590                            _fill_in_blank_answer_parent.parents('.ays-abs-fs').css({
2591                                'padding': '7px'
2592                            });
2593                        }else{
2594                            if(parseInt(fill_in_blank_answer.next().val()) == 1){
2595                                fill_in_blank_answer.css('background-color', 'rgba(39,174,96,0.5)');
2596                                fill_in_blank_answer.css('width', 'auto');
2597
2598                            }else{
2599                                fill_in_blank_answer.css('background-color', 'rgba(243,134,129,0.4)');
2600                                fill_in_blank_answer.css('width', 'auto');
2601
2602                                if( is_user_answer_correct ){
2603                                    is_user_answer_correct = false;
2604                                }
2605
2606                                if(showOnlyWrongAnswer === false){
2607                                    // var rightAnswerText = '<div class="ays-text-right-answer">';
2608                                    // var thisQuestionAnswer = fill_in_blank_answer.attr('chishtpatasxan');
2609                                    // if(typeof thisQuestionAnswer != 'undefined'){
2610                                    //     thisQuestionAnswer = aysEscapeHtmlDecode( thisQuestionAnswer ).aysStripSlashes();
2611                                    //     thisQuestionAnswer = thisQuestionAnswer.split('%%%');
2612                                    // }else{
2613                                    //     thisQuestionAnswer = [''];
2614                                    // }
2615                                    // rightAnswerText += thisQuestionAnswer[0].trim();
2616
2617                                    // rightAnswerText += '</div>';
2618                                    // if(fill_in_blank_answer.parents('.ays_quiz_question').find('.ays-text-right-answer').length == 0){
2619                                    //     fill_in_blank_answer.parents('.ays_quiz_question').append(rightAnswerText);
2620                                    // }
2621                                    // fill_in_blank_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2622                                    //     'display': 'block'
2623                                    // });
2624                                    fill_in_blank_answer.parents('.ays-abs-fs').find('.ays_quiz_question_text_conteiner').addClass('ays_display_none');
2625                                }
2626                            }
2627
2628                            
2629                        }
2630                    }
2631
2632                    if( fillInBlankAnswers_last ){
2633                        if( is_user_answer_correct === true ){
2634                            answerIsRight = true;
2635                            if (correct_img_URL_HTML != "") {
2636                                var if_img_exists = $( fillInBlankAnswers[0] ).parents('.ays_quiz_question').find(".ays-quiz-check-button-right-wrong-icon");
2637                                if ( if_img_exists.length <= 0 ) {
2638                                    $( fillInBlankAnswers[0] ).parent().append(correct_img_URL_HTML);
2639                                }
2640                            }
2641                        } else {
2642                            if (wrong_img_URL_HTML != "") {
2643                                var if_img_exists = $( fillInBlankAnswers[0] ).parents('.ays_quiz_question').find(".ays-quiz-check-button-right-wrong-icon");
2644                                if ( if_img_exists.length <= 0 ) {
2645                                    $( fillInBlankAnswers[0] ).parent().append(wrong_img_URL_HTML);
2646                                }
2647                            }
2648
2649                            var thisAnswerOptions = myQuizOptions[questionId];
2650                            var thisQuestionAnswer = (typeof myQuizOptions[questionId].question_answer != 'undefined') ? myQuizOptions[questionId].question_answer : new Array();
2651
2652                            var rightAnswerTextStart = "";
2653                            var rightAnswerTextEnd = "";
2654                            rightAnswerTextStart += '<div class="ays-quiz-answers" style="pointer-events: none;">';
2655                                rightAnswerTextStart += '<div class="ays-text-right-answer" style="display: block;">';
2656
2657                                rightAnswerTextEnd += '<div';
2658                            rightAnswerTextEnd += '<div';
2659
2660                            if(typeof thisQuestionAnswer != 'undefined'){
2661                                var only_question_original_html_clone = $( rightAnswerTextStart + question_original_html_clone.html() + rightAnswerTextEnd);
2662
2663                                for( var answerId in thisQuestionAnswer ) {
2664
2665                                    var rightAnswerText = aysEscapeHtmlDecode( thisQuestionAnswer[answerId] ).aysStripSlashes();
2666                                    rightAnswerText = rightAnswerText.split('%%%');
2667                                    rightAnswerText = rightAnswerText[0].trim();
2668
2669                                    var rightAnswerHTML = $('<strong class="ays-quiz-fill-in-blank-input-right-wrong-answer">'+ rightAnswerText +'</strong>');
2670
2671                                    var fill_in_blank_answer_input = only_question_original_html_clone.find('.ays-quiz-fill-in-blank-input[data-answer-id="'+ answerId +'"]');
2672
2673                                    fill_in_blank_answer_input.replaceWith( rightAnswerHTML );
2674                                }
2675
2676                                fill_in_blank_answer.parents('.ays_quiz_question').append(only_question_original_html_clone);
2677                                fill_in_blank_answer.parents('.ays_quiz_question').find('script').remove();
2678
2679                            }
2680                        }
2681                    }
2682                }
2683
2684                if(date_answer.val() == ''){
2685                    if(showOnlyWrongAnswer === false){
2686                        var rightAnswerText = '<div class="ays-text-right-answer">';
2687                        var thisQuestionAnswer = date_answer.attr('chishtpatasxan');
2688
2689                        var correctDate = new Date(thisQuestionAnswer),
2690                            correctDateYear = correctDate.getUTCFullYear(),
2691                            correctDateMonth = (correctDate.getUTCMonth() + 1) < 10 ? "0"+(correctDate.getUTCMonth() + 1) : (correctDate.getUTCMonth() + 1),
2692                            correctDateDay = (correctDate.getUTCDate() < 10) ? "0"+correctDate.getUTCDate() : correctDate.getUTCDate();
2693                        rightAnswerText += [correctDateMonth, correctDateDay, correctDateYear].join('/');
2694
2695                        rightAnswerText += '</div>';
2696                        if(date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2697                            date_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2698                        }
2699                        date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2700                            'display': 'block'
2701                        });
2702                    }
2703                    date_answer.css('background-color', 'rgba(243,134,129,0.8)');
2704
2705                    if (wrong_img_URL_HTML != "") {
2706                        var if_img_exists = date_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2707                        if ( if_img_exists.length <= 0 ) {
2708                            date_answer.parent().append(wrong_img_URL_HTML);
2709                        }
2710                    }
2711
2712                    var _date_answer_parent = date_answer.parents('.ays-abs-fs');
2713
2714                    _date_answer_parent.html(fieldset_html);
2715                    _date_answer_parent.find('.ays_fieldset').append(ays_quiz_question_html);
2716                    _date_answer_parent.find('.ays_fieldset').append(ays_quiz_question_img_html);
2717         
2717           _date_answer_parent.find('.ays_fieldset').append(date_answer.parents('.ays-quiz-answers'));
2718                    
2719                    for (var i = 0; i < question_parts_arr.length; i++) {
2720                        _date_answer_parent.find('.ays_fieldset').append( question_parts_arr[i] );
2721                    }
2722
2723                    date_answer.parents('.ays-abs-fs').css({
2724                        'padding': '7px'
2725                    });
2726                }else{
2727                    if(parseInt(date_answer.next().val()) == 1){
2728                        date_answer.css('background-color', 'rgba(39,174,96,0.5)');
2729                        answerIsRight = true;
2730
2731                        if (correct_img_URL_HTML != "") {
2732                            var if_img_exists = date_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2733                            if ( if_img_exists.length <= 0 ) {
2734                                date_answer.parent().append(correct_img_URL_HTML);
2735                            }
2736                        }
2737
2738                    }else{
2739                        date_answer.css('background-color', 'rgba(243,134,129,0.4)');
2740
2741                        if (wrong_img_URL_HTML != "") {
2742                            var if_img_exists = date_answer.parent().find(".ays-quiz-check-button-right-wrong-icon");
2743                            if ( if_img_exists.length <= 0 ) {
2744                                date_answer.parent().append(wrong_img_URL_HTML);
2745                            }
2746                        }
2747
2748                        if(showOnlyWrongAnswer === false){
2749                            var rightAnswerText = '<div class="ays-text-right-answer">';
2750                            var thisQuestionAnswer = date_answer.attr('chishtpatasxan');
2751                            var correctDate = new Date(thisQuestionAnswer),
2752                                correctDateYear = correctDate.getFullYear(),
2753                                correctDateMonth = (correctDate.getMonth() + 1) < 10 ? "0"+(correctDate.getMonth() + 1) : (correctDate.getMonth() + 1),
2754                                correctDateDay = (correctDate.getDate() < 10) ? "0"+correctDate.getDate() : correctDate.getDate();
2755                            rightAnswerText += [correctDateMonth, correctDateDay, correctDateYear].join('/');
2756
2757                            rightAnswerText += '</div>';
2758                            if(date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').length == 0){
2759                                date_answer.parents('.ays-quiz-answers').append(rightAnswerText);
2760                            }
2761                            date_answer.parents('.ays-quiz-answers').find('.ays-text-right-answer').css({
2762                                'display': 'block'
2763                            });
2764                        }
2765                    }
2766                }
2767
2768                if (checked_inputs.length === 1) {
2769                    if(parseInt(checked_inputs.prev().val()) === 1){
2770                        checked_inputs.parent().addClass('checked_answer_div').addClass('correct_div');
2771                        checked_inputs.parent().find('label').addClass('correct answered');
2772                        answerIsRight = true;
2773                        if(form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
2774                           form.parents('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
2775                            $(checked_inputs).next().css('background-color', "transparent");
2776                            $(checked_inputs).parent().css('background-color', ' rgba(158,208,100,0.8)');
2777                        }
2778                    }else{
2779                        if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
2780                           $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
2781                            $(checked_inputs).next().css('background-color', "transparent");
2782                            $(checked_inputs).parent().css('background-color', ' rgba(243,134,129,0.8)');
2783                        }
2784                        checked_inputs.parent().addClass('checked_answer_div').addClass('wrong_div');
2785                        checked_inputs.parent().find('label').addClass('wrong wrong_div answered');
2786                    }
2787
2788                    if($(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') ||
2789                       $(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){
2790                        $(this).next().css('padding', "0 10px 0 10px");
2791                    }
2792                    $(checked_inputs).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', true);
2793                }else if(checked_inputs.length > 1){
2794                    var checked_right = 0;
2795                    checked_inputs.map(function() {
2796                        if(parseInt($(this).prev().val()) === 1){
2797                            $(this).parent().addClass('checked_answer_div').addClass('correct_div');
2798                            $(this).parent().find('label').addClass('correct answered');
2799                            if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
2800                               $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
2801                                $(this).next().css('background-color', "transparent");
2802                                $(this).parent().css('background-color', ' rgba(158,208,100,0.8)');
2803                            }
2804                        }else{ 
2805                            $(this).parent().addClass('checked_answer_div').addClass('wrong_div');
2806                            $(this).parent().find('label').addClass('wrong wrong_div answered');
2807                            checked_right++;
2808                            if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
2809                               $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
2810                                $(this).next().css('background-color', "transparent");
2811                                $(this).parent().css('background-color', ' rgba(243,134,129,0.8)');
2812                            }
2813                        }
2814                        if($(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_dark') ||
2815                           $(document).find('.ays-quiz-container').hasClass('ays_quiz_modern_light')){
2816                        }
2817
2818                        if($(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_dark') ||
2819                           $(document).find('.ays-quiz-container').hasClass('ays_quiz_elegant_light')){
2820                        }
2821                        $(this).parents().eq(3).find('input[name^="ays_questions"]').attr('disabled', true);
2822                    });
2823                    if(checked_right == 0){
2824                        answerIsRight = true;
2825                    }
2826                }
2827
2828                if(answerIsRight && un_checked_inputs.length > 0){
2829                    var un_checked_right = 0;
2830                    un_checked_inputs.map(function() {
2831                        if($(this).parent().hasClass('correct_div')){
2832                            un_checked_right++;
2833                        }
2834                    });
2835                    if(un_checked_right > 0){
2836                        answerIsRight = false;
2837                    }
2838                }
2839
2840                if (hideRightAnswers) {
2841                    question.find('.ays-text-right-answer').addClass("ays_quiz_display_none_important");
2842                    var aysFieldsets = question.find('fieldset.ays_fieldset');
2843                    if (aysFieldsets.length > 0) {
2844                        var aysFieldsetsField = aysFieldsets.find('.ays-field');
2845                        if (aysFieldsetsField.hasClass('correct_div')) {
2846                            aysFieldsetsField.removeClass('correct_div');
2847                        }
2848                        if (aysFieldsetsField.hasClass('checked_answer_div')) {
2849                            aysFieldsetsField.removeClass('checked_answer_div');
2850                        }
2851                        if (aysFieldsetsField.find('label').hasClass('correct')) {
2852                            aysFieldsetsField.find('label').removeClass('correct');
2853                        }
2854                    }
2855                    var answers_box = question.find('.ays-quiz-answers');
2856                    if (answers_box.length > 0) {
2857                        answers_box.each(function () {
2858                           var userWrongAnswered = $(this).find('.ays-field');
2859                           var userWrongAnsweredLabel = userWrongAnswered.find('label');
2860                           var questionTypeCheckbox = userWrongAnswered.find('input[type="checkbox"]');
2861                           if (userWrongAnsweredLabel.hasClass('wrong') || questionTypeCheckbox.length > 0) {
2862                                if (userWrongAnsweredLabel.hasClass('correct') && userWrongAnsweredLabel.hasClass('answered')) {
2863                                    var eachAnswers = userWrongAnswered.find('input[name^="ays_questions"]');
2864                                    if (eachAnswers.length > 0) {
2865                                        eachAnswers.each(function () {
2866                                            var parentBox = $(this).parents('.ays-field');
2867                                            if (! $(this).prop("checked")) {
2868                                                $(this).next().removeClass('correct');
2869                                                if (parentBox.hasClass('correct_div')) {
2870                                                    answerIsRight = false;
2871                                                    parentBox.removeClass('correct_div');
2872                                                }
2873                                                if (parentBox.hasClass('checked_answer_div')) {
2874                                                    parentBox.removeClass('checked_answer_div');
2875                                                }
2876                                                if (! parentBox.hasClass('.checked_answer_div') ) {
2877                                                    parentBox.find('input~label.answered.correct').addClass('ays_quiz_hide_correct_answer');
2878                                                }
2879                                            }
2880                                        });
2881                                    }
2882                                }
2883                           }
2884                        });
2885                    }
2886                }
2887
2888                answerIsRightArr[ 'questionId_' + questionId ] = answerIsRight;
2889
2890                if(myOptions.answers_rw_texts && (myOptions.answers_rw_texts == 'on_results_page' || myOptions.answers_rw_texts == 'on_both')){
2891                    if(answerIsRight){
2892                        question.find('.right_answer_text').css("display", "block");
2893                    }else{
2894                        question.find('.wrong_answer_text').css("display", "block");
2895                    }
2896                }else{
2897                    question.find('.right_answer_text').css("display", "none");
2898                    question.find('.wrong_answer_text').css("display", "none");
2899                }
2900                // question.find('.ays_questtion_explanation').css("display", "block");
2901                var showExplanationOn = (myOptions.show_questions_explanation && myOptions.show_questions_explanation != "") ? myOptions.show_questions_explanation : "on_results_page";
2902                if(showExplanationOn == 'on_results_page' || showExplanationOn == 'on_both'){
2903                    if(! question.hasClass('not_influence_to_score')){
2904                        question.find('.ays_questtion_explanation').css("display", "block");
2905                    }
2906                }else{
2907                    question.find('.ays_questtion_explanation').css("display", "none");
2908                }
2909                question.find('.ays_user_explanation').css("display", "none");
2910                question.css("pointer-events", "auto");
2911                question.find('.ays-quiz-answers').css("pointer-events", "none");
2912
2913                question.find('.ays-quiz-answers .ays-field input').removeAttr("name").removeAttr("id");
2914
2915                formResults.append(question);
2916            }
2917
2918            myOptions.quiz_show_wrong_answers_first = ! myOptions.quiz_show_wrong_answers_first ? 'off' : myOptions.quiz_show_wrong_answers_first;
2919            var quiz_show_wrong_answers_first = (myOptions.quiz_show_wrong_answers_first && myOptions.quiz_show_wrong_answers_first == 'on') ? true : false;
2920
2921            myOptions.quiz_show_only_wrong_answers = ! myOptions.quiz_show_only_wrong_answers ? 'off' : myOptions.quiz_show_only_wrong_answers;
2922            var quiz_show_only_wrong_answers = (myOptions.quiz_show_only_wrong_answers && myOptions.quiz_show_only_wrong_answers == 'on') ? true : false;
2923
2924            if ( quiz_show_wrong_answers_first || quiz_show_only_wrong_answers) {
2925                var UserAnswered_true_arr  = new Array();
2926                var UserAnswered_false_arr = new Array();
2927                var UnAnswered_arr = new Array(); 
2928                for (var question_ID in answerIsRightArr) {
2929
2930                    var question_ID_arr = question_ID.split("_");
2931                    var questionDataID  = question_ID_arr[1];
2932
2933                    var UserAnswered_true_or_false = answerIsRightArr[question_ID];
2934
2935                    var isNotAnswered = form.find('.ays_quiz_results div.ays_question_result[data-question-id="'+ questionDataID +'"]').has('.ays_fieldset');
2936                    if (isNotAnswered.length > 0 ){
2937                        isNotAnswered = true;
2938                    }
2939                    else{
2940                        isNotAnswered = false;
2941                    }
2942
2943                    var questionHTML = form.find('.ays_quiz_results div.ays_question_result[data-question-id="'+ questionDataID +'"]').clone();
2944
2945                    if ( UserAnswered_true_or_false ) {
2946                        UserAnswered_true_arr.push( questionHTML );
2947                    } else if(!isNotAnswered){
2948                        UserAnswered_false_arr.push( questionHTML );
2949                    }
2950                    else{
2951                        UnAnswered_arr.push( questionHTML );
2952                    }
2953                }
2954
2955                if ( quiz_show_only_wrong_answers ) {
2956                    UserAnswered_true_arr = new Array();
2957                }
2958
2959                var allQuestionHTML = UserAnswered_false_arr.concat( 
2959UnAnswered_arr ).concat( UserAnswered_true_arr );
2960
2961                formResults.html('');
2962
2963                if ( quiz_enable_results_toggle ) {
2964                    formResults.append(resultToggleHTML);
2965                }
2966
2967                for (var ii = 0; ii < allQuestionHTML.length; ii++) {
2968                    formResults.append( allQuestionHTML[ii] );
2969                }
2970            }
2971        }
2972        
2973        var showResults = true;
2974        if ( (myOptions.enable_paypal && myOptions.enable_paypal === 'on') || 
2975            ( myOptions.enable_stripe && myOptions.enable_stripe === 'on' )  || 
2976            ( myOptions.enable_razorpay && myOptions.enable_razorpay === 'on' ) ) {
2977            if (myOptions.payment_type && myOptions.payment_type === 'postpay') {
2978                showResults = false;
2979            }else{
2980                showResults = true;
2981            }
2982        }
2983
2984        if( showResults === true ){
2985            form.find('.ays_quiz_results').slideDown(1000);
2986        }
2987
2988        form.find('.ays_quiz_rete').fadeIn(250);
2989        form.find('.for_quiz_rate').rating({
2990            onRate: function(res){
2991                // $(this).rating('disable');
2992                $(this).parent().find('.for_quiz_rate_reason').slideDown(500);
2993                $(this).parents('.ays_quiz_rete').attr('data-rate_score', res);
2994            }
2995        });
2996
2997        if( quiz_enable_keyboard_navigation ){
2998            form.find('.for_quiz_rate > i').addClass('ays-quiz-keyboard-active');
2999            form.find('.for_quiz_rate > i').attr('tabindex', '0');
3000        }
3001
3002        var aysQuizLoader = form.find('div[data-role="loader"]');
3003        aysQuizLoader.addClass('ays-loader');
3004        aysQuizLoader.removeClass(aysQuizLoader.data('class'));
3005        aysQuizLoader.find('.ays-loader-content').css('display','none');
3006
3007        var openResultsPage = true;
3008        window.aysResultsForQuizStored = false;
3009        if ( (myOptions.enable_paypal && myOptions.enable_paypal === 'on') || 
3010            (myOptions.enable_stripe && myOptions.enable_stripe === 'on') || 
3011            (myOptions.enable_razorpay && myOptions.enable_razorpay === 'on') ) {
3012            if (myOptions.payment_type && myOptions.payment_type === 'prepay') {
3013                openResultsPage = true;
3014            }else{
3015                openResultsPage = false;
3016                if( !window.aysResultsForQuizStored ) {
3017                    window.aysResultsForQuiz = form.find('.ays_quiz_results_page').html();
3018                    window.aysResultsForQuizStored = true;
3019                    form.find('.ays_quiz_results_page').html('');
3020                }
3021            }
3022        }
3023
3024        if( openResultsPage === true ){
3025            form.find('.ays_quiz_results_page').css({'display':'block'});
3026        }
3027
3028        form.find('.ays_paypal_wrap_div, .ays_stripe_wrap_div, .ays_razorpay_wrap_div').css({'display':'block'});
3029        form.find('.ays_paypal_wrap_div, .ays_stripe_wrap_div, .ays_razorpay_wrap_div').attr('data-result', response.result_id);
3030
3031        form.css({'display':'block'});
3032
3033        aysResizeiFrame();
3034
3035        form.on('click', '.ays_quiz_rete .for_quiz_rate_reason .action-button', function(){
3036
3037            var _this = $(this);
3038            var _parent = _this.parents('.for_quiz_rate_reason');
3039            
3040            if(myOptions.quiz_make_review_required == 'on' && myOptions.quiz_make_review_required == 'on'){
3041
3042                var _el = _parent.find('.quiz_rate_reason[data-required="true"]');
3043
3044                if ( ! _this.hasClass('start_button') ) {
3045                    if ( _el.length !== 0 ) {
3046                        var empty_inputs = 0;
3047
3048                        if (_el.val().trim() === '' &&
3049                            _el.attr('type') !== 'hidden') {
3050                            _el.addClass('ays_red_border');
3051                            _el.addClass('ays_animated_x5ms');
3052                            _el.addClass('shake');
3053                            empty_inputs++;
3054                        }
3055
3056                        var errorFields = _parent.find('.ays_red_border');
3057                        if ( empty_inputs !== 0 ) {
3058                            setTimeout(function(){
3059                                errorFields.each(function(){
3060                                    $(this).removeClass('shake');
3061                                });
3062                            }, 500);
3063                            return false;
3064                        }
3065                    }
3066                }
3067            }
3068
3069            $(this).parents('.for_quiz_rate_reason').find('.quiz_rate_reason').attr('disabled', 'disabled');
3070            var data = {};
3071            var quizId = form.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
3072            var quizCusrrentPageLink = form.parents('.ays-quiz-container').find('input[name="ays_quiz_curent_page_link"]').val();
3073            var enableUserCÕ°oosingCheckbox = form.parents('.ays-quiz-container').find('.ays-quiz-user-cÕ°oosing-anonymous-assessment .ays-quiz-user-cÕ°oosing-anonymous-assessment:checked');
3074            
3075            var enableUserCÕ°oosingCheckboxFlag = false;
3076            if( enableUserCÕ°oosingCheckbox.length > 0 ){
3077            var enableUserCÕ°oosingCheckboxFlag = true;
3078            }
3079
3080            data.action = 'ays_rate_the_quiz';
3081            data.rate_reason = $(this).parents('.for_quiz_rate_reason').find('.quiz_rate_reason').val();
3082            data.rate_score = $(this).parents('.ays_quiz_rete').data('rate_score');
3083            data.rate_date = GetFullDateTime();
3084            data.quiz_id = quizId;
3085            data.last_result_id = last_result_id;
3086            data.quiz_make_responses_anonymous = quiz_make_responses_anonymous;
3087            data.quiz_current_page_link = quizCusrrentPageLink;
3088            data.quiz_enable_user_cÕ°oosing_anonymous_assessment = quiz_enable_user_cÕ°oosing_anonymous_assessment;
3089            data.quiz_enable_user_cÕ°oosing_anonymous_assessment_checkbox_flag = enableUserCÕ°oosingCheckboxFlag;
3090            form.find('.for_quiz_rate_reason').slideUp(800);
3091            var showAvgRate = false;
3092            myOptions.show_rate_after_rate = (myOptions.show_rate_after_rate) ? myOptions.show_rate_after_rate : 'on';
3093            if(myOptions.show_rate_after_rate && myOptions.show_rate_after_rate == 'on'){
3094                showAvgRate = true;
3095            }
3096            if(showAvgRate){
3097                $(this).parents('.ays_quiz_rete').find('.lds-spinner-none').addClass('lds-spinner').removeClass('lds-spinner-none');
3098            }
3099            if(myOptions.enable_quiz_rate == 'on' && myOptions.enable_rate_comments == 'on'){
3100                $(this).parents('.ays_quiz_rete').find('.lds-spinner2-none').addClass('lds-spinner2').removeClass('lds-spinner2-none');
3101            }
3102            $.ajax({
3103                url: quiz_maker_ajax_public.ajax_url,
3104                method: 'post',
3105                dataType: 'json',
3106                crossDomain: true,
3107                data: data,
3108                success: function(response){
3109                    if(response.status === true){
3110                        setTimeout(function(){
3111                            form.find('.ays_quiz_rete').find('.for_quiz_rate').attr('data-rating', response.score);
3112                            form.find('.ays_quiz_rete').find('.for_quiz_rate').rating({
3113                                initialRating: response.score
3114                            });
3115                            form.find('.ays_quiz_rete').find('.for_quiz_rate').rating('disable');
3116                            form.find('.ays_quiz_rete').find('.ays-quiz-user-cÕ°oosing-anonymous-assessment').hide();
3117                            if(showAvgRate){
3118                                form.find('.lds-spinner').addClass('lds-spinner-none').removeClass('lds-spinner');
3119                                form.find('.for_quiz_rate_reason').html('<p>'+response.rates_count + ' ' + quizLangObj.votes + ', ' + response.avg_score + ' ' + quizLangObj.avg + ' </p>');
3120                                form.find('.for_quiz_rate_reason').fadeIn(250);
3121                            }
3122
3123                            var review_ty_message = form.find('.ays-quiz-review-thank-you-message');
3124                            if ( review_ty_message.length > 0 ) {
3125                                if ( review_ty_message.hasClass('ays_display_none') ) {
3126                                    review_ty_message.removeClass('ays_display_none');
3127                                }
3128                            }
3129
3130                            if(myOptions.enable_quiz_rate == 'on' && myOptions.enable_rate_comments == 'on'){
3131                                var data = {};
3132                                data.action = 'ays_get_rate_last_reviews';
3133                                data.quiz_id = response.quiz_id;
3134                                $.ajax({
3135                                    url: quiz_maker_ajax_public.ajax_url,
3136                                    method: 'post',
3137                                    crossDomain: true,
3138                                    data: data,
3139                                    success: function(response){
3140                                        var response_arr = JSON.parse(response);
3141                                        var responseHTML = (response_arr.quiz_rate_html && response_arr.quiz_rate_html != '') ? response_arr.quiz_rate_html : '';
3142
3143                                        form.find('.quiz_rate_reasons_body').html(responseHTML);
3144                                        form.find('.lds-spinner2').addClass('lds-spinner2-none').removeClass('lds-spinner2');
3145                                        form.find('.quiz_rate_reasons_container').slideDown(500);
3146                                        form.find('.ays-quiz-rate-link-box .ays-quiz-rate-link').slideUp(500);
3147                                        form.on('click', 'button.ays_load_more_review', function(e){
3148                                            form.find('.quiz_rate_load_more [data-role="loader"]').addClass(form.find('.quiz_rate_load_more .ays-loader').data('class')).removeClass('ays-loader');
3149                                            var startFrom = parseInt($(e.target).attr('startfrom'));
3150                                            var zuyga = parseInt($(e.target).attr('zuyga'));
3151                                            $.ajax({
3152                                                url: quiz_maker_ajax_public.ajax_url,
3153                                                method: 'post',
3154                                                crossDomain: true,
3155                                                data:{
3156                                                    action: 'ays_load_more_reviews',
3157                                                    quiz_id: quizId,
3158                                                    start_from: startFrom,
3159                                                    zuyga: zuyga
3160                                                },
3161                                                success: function(resp){
3162                                                    if(zuyga == 0){
3163                                                        zuyga = 1;
3164                                                    }else{
3165                                                        zuyga = 0;
3166                                                    }
3167                                                    
3168                                                    form.find('.quiz_rate_load_more [data-role="loader"]').addClass('ays-loader').removeClass(form.find('.quiz_rate_load_more .ays-loader').data('class'));
3169                                                    form.find('.quiz_rate_reasons_container').append(resp);
3170                                                    form.find('.quiz_rate_more_review:last-of-type').slideDown(500);
3171                                                    $(e.target).attr('startfrom', startFrom + 5 );
3172                                                    $(e.target).attr('zuyga', zuyga);
3173                                                    if(form.find('.quiz_rate_reasons_container p.ays_no_more').length > 0){
3174                                                        $(e.target).remove();
3175                                                    }
3176                                                }
3177                                            });
3178                                        });
3179                                    },
3180                                    error: function(jqXHR, textStatus, errorThrown) {}
3181                                });
3182                            }
3183                        },1000);
3184                    }
3185                }
3186            });
3187        });
3188    }
3189
3190    function redirect_timer(timer, args) {
3191        if( typeof args == 'undefined' ){
3192           args = {};
3193        }
3194
3195        var tabTitle = document.title;
3196
3197        var countDownDate = new Date().getTime() + (timer * 1000);
3198
3199        var x = setInterval(function () {
3200            var now = new Date().getTime();
3201            var distance = countDownDate - Math.ceil(now/1000)*1000;
3202            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
3203            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
3204            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
3205            var timeForShow = "";
3206            if(hours <= 0){
3207                hours = null;
3208            }else if (hours < 10) {
3209                hours = '0' + hours;
3210            }
3211            if (minutes < 10) {
3212                minutes = '0' + minutes;
3213            }
3214            if (seconds < 10) {
3215                seconds = '0' + seconds;
3216            }
3217            timeForShow =  ((hours==null)? "" : (hours + ":")) + minutes + ":" + seconds;
3218            if(distance <=1000){
3219                timeForShow = ((hours==null) ? "" : "00:") + "00:00";
3220                $(document).find('.ays-quiz-container').find('div.ays-quiz-redirection-timer').html(timeForShow);
3221                document.title = timeForShow + " - " + tabTitle;
3222            }else{
3223                 $(document).find('.ays-quiz-container').find('div.ays-quiz-redirection-timer').html(timeForShow);
3224                document.title = timeForShow + " - " + tabTitle;
3225            }
3226            $(document).find('.ays-quiz-container').find('div.ays-quiz-redirection-timer').slideDown(500);
3227            var ays_interval_element_redirect_url = args.redirectUrl;
3228
3229            if (distance <= 1000) {
3230                clearInterval(x);
3231                if (window.location != window.parent.location) {
3232                    window.parent.location = ays_interval_element_redirect_url;
3233                } else {
3234                    window.location = ays_interval_element_redirect_url;
3235                }
3236            }
3237        }, 1000);
3238    }
3239    
3240    function redirectAction(redirectUrl, redirectDelay, blockElement, redirectAfter, form, myOptions, redirectMessageFlag, uniqueCode){
3241        redirectUrl = redirectUrl.includes('?') ? redirectUrl.replace('[uniquecode]', "&uniquecode=" + uniqueCode ) : redirectUrl.replace('[uniquecode]', "?uniquecode=" + uniqueCode);
3242
3243        var timer = parseInt(redirectDelay);
3244        if(timer === NaN){
3245            timer = 0;
3246        }
3247
3248        if( timer == 0 ){
3249            if (window.location != window.parent.location) {
3250                window.parent.location = redirectUrl;
3251            } else {
3252                window.location = redirectUrl;
3253            }
3254            return false;
3255        }
3256
3257        if ( redirectMessageFlag ) {
3258            var quizId = form.parents('.ays-quiz-container').find('input[name="ays_quiz_id"]').val();
3259            // Message before redirect timer
3260            var quiz_message_before_redirect_timer = (myOptions.quiz_message_before_redirect_timer && myOptions.quiz_message_before_redirect_timer != "") ? ( myOptions.quiz_message_before_redirect_timer ) : '';
3261
3262            if ( quiz_message_before_redirect_timer != '' ) {
3263                quiz_message_before_redirect_timer = quiz_message_before_redirect_timer.replace(/(["'])/g, "\\$1") + " ";
3264
3265                $(document).find('html > head').append('<style> #ays-quiz-container-'+ quizId +' div.ays-quiz-redirection-timer:before{content: "'+ quiz_message_before_redirect_timer +'"; }</style>');
3266            }
3267        }
3268
3269        var tabTitle = document.title;
3270        var timerText = $('<section class="ays_quiz_redirection_timer_container">'+
3271            '<div class="ays-quiz-redirection-timer">'+
3272            quizLangObj.redirectAfter + ' ' + redirectAfter +
3273            '</div><hr></section>');
3274        form.parents('.ays-quiz-container').prepend(timerText);
3275        blockElement.find('.ays_quiz_redirection_timer_container').css({
3276            height: 'auto'
3277        });
3278        setTimeout(function(){
3279            if (timer !== NaN) {
3280                timer += 2;
3281                if (timer !== undefined) {
3282                    blockElement.find('div.ays-quiz-redirection-timer').slideUp(500);
3283                    redirect_timer( timer,  {
3284                        redirectUrl: redirectUrl
3285                    });
3286                }
3287            }
3288        }, 2000);
3289
3290        return true;
3291    }
3292
3293    function aysQuizSetCustomEvent() {
3294        if ( typeof window.CustomEvent === "function" ) return false; //If not IE
3295    
3296        function CustomEvent ( event, params ) {
3297            params = params || { bubbles: false, cancelable: false, detail: undefined };
3298            var evt = document.createEvent( 'CustomEvent' );
3299            evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
3300            return evt;
3301        }
3302    
3303        CustomEvent.prototype = window.Event.prototype;
3304    
3305        window.CustomEvent = CustomEvent;
3306    }
3307
3308    function checkQuestionTimer( container, quizId ){
3309        if( window.aysQuizQuestionTimers[quizId] ) {
3310            var questions = container.find('div[data-question-id]');
3311            var remainingQuestionsEmpty = [];
3312            for (var i = 0; i < questions.length; i++) {
3313                var questionID = questions[i].dataset.questionId;
3314
3315                if(
3316                    window.aysQuizQuestionTimers[quizId][questionID]
3317                    &&
3318                    (
3319                        window.aysQuizQuestionTimers[quizId][questionID].ended === true
3320                        ||
3321                        window.aysQuizQuestionTimers[quizId][questionID].stopped === true
3322                    )
3323                ){
3324                    continue;
3325                }else{
3326                    if ( ays_quiz_is_question_empty( $(questions[i]) ) === false ) {
3327                        remainingQuestionsEmpty.push({
3328                            item: $(questions[i]),
3329                            id: questionID
3330                        });
3331                    }
3332                }
3333            }
3334
3335            if( remainingQuestionsEmpty.length > 0 ){
3336                return remainingQuestionsEmpty[0].id;
3337            }else{
3338                return false;
3339            }
3340        }
3341        
3342        return false;
3343    }
3344
3345    function stopQuestionTimer( questionID, quizId, myOptions ){
3346        if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
3347            if (myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'question_timer') {
3348                if (window.aysQuizQuestionTimers && window.aysQuizQuestionTimers[quizId]) {
3349                    if (window.aysQuizQuestionTimers[quizId][questionID] !== null) {
3350                        clearInterval(window.aysQuizQuestionTimers[quizId][questionID].timeout);
3351                        window.aysQuizQuestionTimers[quizId][questionID].stopped = true;
3352                        window.aysQuizQuestionTimers[quizId][questionID].ended = true;
3353                    }
3354                }
3355            }
3356        }
3357    }
3358
3359    // function stopQuestionTimer( container, questionID, myOptions ){
3360    //     if( myOptions.enable_timer && myOptions.enable_timer === 'on' ) {
3361    //         if (myOptions.quiz_timer_type && myOptions.quiz_timer_type === 'question_timer') {
3362    //             if (window.aysQuizQuestionTimers && window.aysQuizQuestionTimers[quizId]) {
3363    //                 if (window.aysQuizQuestionTimers[quizId][questionID] !== null) {
3364    //                     // clearInterval(window.aysQuizQuestionTimers[quizId][questionID].timeout);
3365    //                     window.aysQuizQuestionTimers[quizId][questionID].stopped = true;
3366    //                     var qid = checkQuestionTimer( container, quizId );
3367    //                     if (qid === false) {
3368    //                         container.find('input.ays_finish').addClass('ays-quiz-after-timer-end');
3369    //                     }
3370    //                 }
3371    //             }
3372    //         }
3373    //     }
3374    // }
3375
3376    function uploadFile(data, mainBox, fileName){
3377        var _this = this;
3378        $.ajax({
3379            url: window.quiz_maker_ajax_public.ajax_url,
3380            method: 'post',
3381            dataType: 'json',
3382            data: data,
3383            contentType: false,
3384            processData: false,
3385            success: function (response) {
3386                if(response.status){
3387                    if( mainBox.hasClass('ays_red_border') ){
3388                        mainBox.removeClass('ays_red_border');
3389                    }
3390                    if( mainBox.hasClass('ays_green_border') ){
3391                        mainBox.removeClass('ays_green_border');
3392                    }
3393
3394                    mainBox.addClass('ays_green_border');
3395
3396                    var messageBox = mainBox.find('.ays-quiz-upload-ready');
3397                    var messageBoxLink = messageBox.find('.ays-quiz-upload-ready-link');
3398                    var messageBoxHidden = messageBox.find('.ays-quiz-upload-ready-url-link');
3399                    messageBoxLink.html(fileName);
3400                    messageBoxLink.attr("download", fileName);
3401                    messageBoxLink.attr("href", response.fileUrl);
3402                    messageBoxHidden.val(response.fileUrl);
3403                    mainBox.find('.ays-quiz-upload-type').hide();
3404                    mainBox.find('.ays-quiz-upload-type-loader').hide();
3405                    messageBox.show();
3406                }
3407            }
3408        });
3409    }
3410
3411
3412})(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.