• Resolved stuartwaldner

    (@stuartwaldner)


    Hi!

    I’m using a pool of questions and loading 5 at a time.

    Is there a way to have a “load new quiz” or “load next quiz” link or something like that in the results box? If so, that would nice. Otherwise, I guess users need to reload the webpage itself using the browser’s refresh button, right? Is there another option I’m not seeing?

    I’m just looking for an elegant way to keep people loading new quizzes and learning new stuff.

    Thanks,
    Stuart

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    The best way is to probably just add a button/link to the results text (the pass and fail results text) that links back to the page. So you create a link back to the quiz that says “retake quiz” or similar, and when a user selects it, the page reloads with a new set of questions ??

    Thread Starter stuartwaldner

    (@stuartwaldner)

    I’m unclear on how I would link to the “results text?” Keep in mind that my quiz is just one piece of content on a webpage with multiple pieces of content, not a stand-alone webpage.

    Thanks for al your help!

    Best,
    Stuart

    Plugin Author Harmonic Design

    (@harmonic_design)

    This is still possible.

    Browsers can use something called anchors to auto-scroll to a specific place on a page. As long as your site doesn’t do something to break this of course.

    HD Quiz wraps quizzes inside unique IDs that we can use for this very purpose. The ID is hdq_ + ID, where ID is the ID number of the quiz (this can be seen inside the shortcode for each quiz).

    So for example, if your quiz ID is 7, then the anchor ID that we can use will be #hdq_7.

    So let’s pretend that the page with a quiz is https://domain.com/quiz. What you do is add a link to the results text that points to htps://domain.com/quiz#hdq_7. This way once the page reloads, the browser will automatically scroll to the quiz.

    Real case example: Clicking here will reload THIS support page, but auto scroll to your last message. *NOTE: when using this technique, you may want to open the link in a new window/tab. This way the current page doesn’t just scroll.

    Thread Starter stuartwaldner

    (@stuartwaldner)

    Thanks for the support!

    I followed these instructions making the target of the link “_blank” and when I click on the button I created, it simply scrolls up the page to the top of the quiz I just took, and doesn’t open a new quiz on a new tab. Hmmm.

    Any thoughts?

    Thanks,
    Stuart

    Plugin Author Harmonic Design

    (@harmonic_design)

    The only two possibilities are that you either incorrectly added in the target _blank or something on your site (theme or plugin) is “link highjacking” and stopping it from loading in a new tab. I really can’t help more unless I can see a link to the quiz though since there is no way for me to narrow it down

    Thread Starter stuartwaldner

    (@stuartwaldner)

    Here’s the code I see using Inspector on my webpage. Unfortunately, my site is on my local host and not something I can share a link to (yet).

    <span class=”fusion-button-text”>Refresh the page to load a new quiz and test your knowledge again!</span>

    I see its targeting a blank page, but it doesn’t work.

    Thanks,
    Stuart

    Plugin Author Harmonic Design

    (@harmonic_design)

    I’m just going to assume that you have your link properly formatted then. This also means that I unfortunately cannot really help you further. A link not opening in a new window is completely unrelated to HD Quiz and without being able to see the page myself, there is nothing I can do to help debug or track the cause for you.

    At this point, the only advice I can give is the following.

    1) Make sure it’s not a popup blocker or something like that.
    2) Try the generic WordPress debug steps. (switch themes to rule out your theme, disable all plugins except HD Quiz, then re-enable one by one until the problem comes back).

    Assuming that once again, you correctly made your link and that the new window is not being blocked by a popup blocker or something, this means that something on your site is link hijacking (hooking into link clicks to change the default behavior) – which is something that no code should EVER globally do. So if you track down either a feature of your theme or another plugin as the cause, I strongly recommend disabling that feature/plugin.

    If not, the worst-case scenario is that you create it as a normal link (without the quiz ID) so that the page refreshes, but the user has to scroll back to the quiz. Maybe you can place a scrollable link to the quiz at the top of the page for quicker access.

    Thread Starter stuartwaldner

    (@stuartwaldner)

    Hi,

    Thanks for the excellent support and generosity of your time. I greatly appreciate it.

    I tested with another theme and it worked.

    I switch back to my theme and then created a link via text, rather than a button and it opened in another tab! ??

    Thanks again for the great support and plugin! ??

    Stuart

    Hello Dylan,

    I thinks this question is excellent (in my case). I did not dare to ask it! But now I dare…

    I’m not a developer, but i found a code called “location.reload();”.
    https://www.w3schools.com/jsref/met_loc_reload.asp

    Is it possible to include this code inside your plugin tu create a button in the “Quiz Pass” and “Quiz Fail” final window ?
    It could be more convenient (in my case) than to copy-past lots of different URL changing if I rewrite URLs a day (for SEO).
    In my quizzes, I added a text in the final window : ” ? Actualisez la page pour un nouveau quiz”. But I’m really not proud of that ??

    Thanks for your suggestions,

    Michel

    Plugin Author Harmonic Design

    (@harmonic_design)

    @michel92 always feel safe to dare!

    You can go the javascript rout if you want. There are two ways you can do this. You can either embed the function inside the link’s onClick event, or you can add an eventListener.

    For the first, an example would be

    <a href = "#" onClick = "location.reload();">Look at me!</a>

    Just note that the above may have conflicts with your theme, which if is the case you’ll need to use the eventListener method (i can provide instructions if it comes to this)

    Thanks a lot, Dylan ??

    It works ! I’m not a developer, but I put the code in includes/functions.php, just before Facebook and Twitter (hdq_share).
    And I created a css class just for this button.

    You really simplify the life of user ??

    Michel

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Load a new quiz button?’ is closed to new replies.