• Resolved mehdis6211

    (@mehdis6211)


    Hi,

    I recently updated HD Quiz to the latest version. Before the update, you provided me with the following code to automatically start the quiz after a few seconds because some users could not find the Start Quiz button:

    function hdq_mehdis6211_init($data)
    {
        array_push($data->hdq_init, "hdq_mehdis6211_after");
        return $data;
    }
    add_action("hdq_init", "hdq_mehdis6211_init");
    
    function hdq_mehdis6211_after()
    {
    ?>
    <script>
    function hdq_mehdis6211_after(){
        const sel = document.getElementsByClassName("hdq_quiz_start");
        if(sel.length == 0){
            return;
        }
        setTimeout(function(){sel[0].click();}, 1500);
    }
    </script>
    <?php
    }
    add_action("hdq_after", "hdq_mehdis6211_after");
    

    Since updating to the latest version, a small number of users have reported that when they click the “Start Quiz” button, nothing happens and the quiz does not begin.

    I have tested the quizzes myself on multiple PCs and mobile devices, and everything works correctly for me. However, the users who reported the issue were using older Android versions (Android 9, 10, and 11).

    Could you please confirm whether this custom auto-start code is still fully compatible with the latest version of HD Quiz? Has anything changed in the quiz initialization process or the .hdq_quiz_start button that could cause issues on some devices or browsers?

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Dylan – Harmonic Design

    (@dylanharmonicdesign)

    Hi mehdis6211,
    that code should still function without issue.

    It’s not just HD Quiz that had a recent update, but the WordPress core itself to the new v7.

    Right now my theory is that because this is only happening on older devices (thanks for providing that info!), the code is working, but is taking too long to run if there is a bunch of other stuff that needs to happen on your site first. Another possibility is that those devices are so old they are not compatible with WordPress’ security NONCEs being fetched.

    There are two things you can try.

    The first is to do a very small edit to ./hd-quiz/assets/frontend/hdq_script.js

    On line 6 you will see HDQ.nonce();. All you need to do is to move that to the end of the function, just after line 36 HDQ.kb();. This will make it so that if I’m right that those older devices are unable to fetch a nonce, the quiz will still work and load, but be unable to send data anywhere after (example: save results light, or the Secure Answers feature).

    Try this first, clear your site cache, and see if reports still come in.

    If the issue is simply that your site is taking too long to load for these older devices, there is little I can do on HD Quiz side since your users would literally be waiting for something else on your site to load before HD Quiz can begin loading. This issue would be this: start quiz button isn’t clickable until HD Quiz has loaded. If you have a script earlier on the page (such as an ad script or something) that takes a long time to load, because it is loaded higher on the page, it prevents HD Quiz from loading until it completes.

    Thread Starter mehdis6211

    (@mehdis6211)

    Hi,

    Thank you very much for your support and for taking the time to investigate the issue.

    I applied the change you suggested by moving HDQ.nonce(); to the end of the init function, cleared all caches, and tested the quizzes on several devices. Everything is working correctly so far, and I haven’t received any new reports from users about quizzes not starting.

    I really appreciate your help and the detailed explanation. Your support has always been excellent and it helped me troubleshoot the issue much faster.

    Thank you again for your time and assistance!

    Best regards,
    Mehdi

    Plugin Support Dylan – Harmonic Design

    (@dylanharmonicdesign)

    Great! Fingers crossed this fixes the issue for you.

    I’ve just updated the plugin with this change in case anyone else has a similar issue, and so that you don’t need to redo the change every time you update. I didn’t do a “version bump” so for any other users reading this thread, you will need to reinstall HD Quiz to get this change if using v2.2.1

    Thread Starter mehdis6211

    (@mehdis6211)

    Hi Dylan,

    I wanted to give you an update after testing the change you suggested.

    I applied the modification, cleared all caches, and monitored the site for several days (approximately 3–4 days). Initially, everything seemed fine, and I tested the quizzes on multiple devices without any issues.

    However, I am still receiving occasional reports from a small number of users that the quiz does not start when they click the “Start Quiz” button.

    After investigating these reports, I noticed a pattern: the affected users are all using older Android devices. For example, today I checked a user’s device and found they were running Android 8. Previous reports were also from devices running Android 9 and Android 10.

    To verify this, I temporarily rolled back HD Quiz to the previous version, and the affected users reported that the quizzes started working again.

    At the moment, it seems that something introduced in the newer version may be causing compatibility issues with older Android devices, while newer devices and desktop browsers continue to work normally.

    Unfortunately, because my website is used by a large number of driving license students, I had to revert to the previous version to avoid further user complaints.

    Do you have any ideas on what else could be causing this issue specifically on older Android versions? If there is any debugging information, console output, or testing you would like me to collect, I would be happy to help.

    Thank you again for your continued support and assistance.

    Best regards,
    Mehdi

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.