jQuery(document).ready(function ($) {
    $('#mark-as-read').on('click', function (e) {
        e.preventDefault();

        var postId = $(this).data('post-id');
        var $currentItem = $('.list-item.active').first();

        $.ajax({
            url: ajax_object.ajaxurl,
            type: 'POST',
            data: {
                action: 'mark_as_read',
                post_id: postId
            },
            success: function (response) {
                if (response.success) {
                    $currentItem.addClass('success');

                    $.ajax({
                        url: ajax_object.ajaxurl,
                        type: 'POST',
                        data: {
                            action: 'check_all_modules_completed'
                        },
                        success: function (checkRes) {
                            if (
                                checkRes.success &&
                                checkRes.data.all_completed
                            ) {
                                window.location.href =
                                    ajax_object.certificate_url;
                            } else {
                                var $allItems = $('.list-item');
                                var currentIndex =
                                    $allItems.index($currentItem);
                                var nextLink = $allItems
                                    .eq(currentIndex + 1)
                                    .find('a')
                                    .attr('href');

                                if (nextLink) {
                                    window.location.href = nextLink;
                                }
                            }
                        }
                    });
                }
            },
            error: function (err) {
                console.error('Ошибка AJAX:', err);
            }
        });
    });
});<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://akadempismo.kz/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://akadempismo.kz/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://akadempismo.kz/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://akadempismo.kz/wp-sitemap-posts-wp_quiz-1.xml</loc></sitemap><sitemap><loc>https://akadempismo.kz/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://akadempismo.kz/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
