function dxSimpleSlider(element = '#dx-slider', auto = false, pause) {

        // Get parent element
        var $this = $(element);

        var submit_btn = $("#submit-quiz");
        $(submit_btn).css("opacity", 0).attr("disabled", true);

        // Slides container
        var slidesCont = $this.children('.slides-container');
        // Get all slides
        var slides = slidesCont.children('.slide');

        // Get Previous / Next links
        var arrowsCont = $this.children('.questionsRow');
        var prevSlide = arrowsCont.children('.prevquestions');
        var nextSlide = arrowsCont.children('.nextquestions');

        // Get pager div
        var pager = arrowsCont.children('.pager');

        // Total slides count
        var slidesCount = slides.length;

        // Set currentSlide to first child
        var currentSlide = slides.first();
        var currentSlideIndex = 1;

        var autoPlay = null;

        // Hide all slides except first and add active class to first
        slides.not(':first').css('display', 'none');
        currentSlide.addClass('active');

        // Function responsible for fading to next slide
        function fadeNext() {
            currentSlide.removeClass('active').fadeOut(700);

            if(currentSlideIndex == slidesCount) {
                $(submit_btn).css("opacity", 1).attr("disabled", false);
                currentSlide = slides.first();
                currentSlide.delay(500).addClass('active').fadeIn(700);
                currentSlideIndex = 1;
            } else {
                currentSlideIndex++;
                currentSlide = currentSlide.next();
                currentSlide.delay(500).addClass('active').fadeIn(700);
            }

            pager.text(currentSlideIndex+' of '+slidesCount);
        }

        // Function responsible for fading to previous slide
        function fadePrev() {
            currentSlide.removeClass('active').fadeOut(700);

            if(currentSlideIndex == 1) {
                currentSlide = slides.last();
                currentSlide.delay(500).addClass('active').fadeIn();
                currentSlideIndex = slidesCount;
            } else {
                currentSlideIndex--;
                currentSlide = currentSlide.prev();
                currentSlide.delay(500).addClass('active').fadeIn(700);
            }

            pager.text(currentSlideIndex+' of '+slidesCount);
        }

        // Function that starts the autoplay and resets it in case user navigated (clicked prev or next)
        function AutoPlay() {
            clearInterval(autoPlay);

            if(auto == true)
                autoPlay = setInterval(function() {fadeNext()}, pause);
        }

        // Detect if user clicked on arrow for next slide and fade next slide if it did
        $(nextSlide).click(function(e) {
            e.preventDefault();
            fadeNext();
            AutoPlay();
        });

        // Detect if user clicked on arrow for previous slide and fade previous slide if it did
        $(prevSlide).click(function(e) {
            e.preventDefault();
            fadePrev();
            AutoPlay();
        });

        // Start autoplay if auto is set to true
        AutoPlay();

    }

    $(function() {
        dxSimpleSlider('#slider', false, 8000);
    });
(function($){
    $.fn.showQuizResult = function(data) {
        if(data !== undefined) {
            // console.log(data);
            var html = "<div class=\"row mb-4\"><div class=\"flashcardcover\"><div class=\"flashcard-container\"><article class=\"flashcard\">Thank you for participating.</article></div></div></div>";
            html += "<div class=\"mt-4\"><a href=\"dashboard\" class=\"btn btn-primary\">Go Back</a></div>";
            $(this).replaceWith(html);
        }
    }
})(jQuery);

jQuery(document).ready(function($){
    var time = $('.countdown').data("time");
    $('.countdown').countdownTimer(time)
    .on('countdownTimer:end', function() { 
        $("#submit-quiz").submitForm();
    })

    var quiz = $("#quiz").val();
    $.ajax({
        type: "post",
        url: "contents/plugins/classroom_plus/ajax.php",
        data: {"quiz": quiz, "action": "cp_init_quiz"}
    }).done(function(){
        //silence
    });

    window.onbeforeunload = function(e) {
        return 'Please press the Logout button to logout.';
    };
})