• Resolved Patrick

    (@pglad)


    Hi, I really like the look of this plugin and have a couple of questions. Firstly, can we have an option to set a pass mark for the quiz instead of a percentage? I would prefer show the number of correct answers rather than display this as a percentage.

    I’m using pagination to display one question per page, but when ‘Start quiz’ is clicked, it shows a ‘next’ button instead of the first questions. Can this be changed to go straight to the first question?

    The page I need help with: [log in to see the link]

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

    (@harmonic_design)

    Hi pglad,
    if you mean the quiz settings, to change the pass percentage to just a number of correct answers needed, then I’m afraid this is not possible ??

    As for the next button: I think you have Paginate enabled on your first question?

    Start a new page with this question
    user will need to select “next” to see this question or ones below it

    So enabling Paginate on a question HIDES that question behind a next button. Hope that makes sense!

    Thread Starter Patrick

    (@pglad)

    That does make sense, but I have set up the quiz to display the questions in a random order, so I don’t know which question will show first.

    Plugin Author Harmonic Design

    (@harmonic_design)

    Ah! The triple combo. Lucky, there is still a work around for that as well.

    Add the following code to your theme’s functions.php file (always make a backup of this file before modifying – just as a fail safe). This code should be added just after the opening <?php tag.

    function hdq_pglad_no_timer_first_q_paginate()
    {
    	?>
    <script>
    function hdq_pglad_no_timer_first_q_paginate(){
    	let start = document.getElementsByClassName("hdq_quiz_start");
    	console.log(start)
    	if(start.length == 0){
    		return;
    	}
    	
    	start[0].addEventListener("click", function(){
    		let results_wrapper = document.getElementsByClassName("hdq_results_wrapper")[0];
    		let next_el = results_wrapper.nextSibling.nextSibling;
    		if(next_el.classList.contains("hdq_jPaginate")){
    			next_el.getElementsByClassName("hdq_next_button")[0].click();
    		}
    	});
    }
    setTimeout(function(){
    	hdq_pglad_no_timer_first_q_paginate();
    }, 500); // create extra opportunity to load
    </script>
    	<?
    }
    add_action("hdq_after", "hdq_pglad_no_timer_first_q_paginate");

    The above code does the following:

    1. Adds a custom script to all quizzes. This script then:
    2. checks to see if a quiz timer is enabled
    3. checks to see if the first question is paginated
    4. if timer is enabled, and the first question is paginated, it will automatically “click” the next button to show the first question

    Let me know if you need any further help

    Thread Starter Patrick

    (@pglad)

    Thanks for that. I added the code, but it generated a syntax error highlighting this line:

    let start = document.getElementsByClassName(“hdq_quiz_start”);

    If I tried to view the page it showed up as a critical error and would not load.

    Regards
    P.

    Plugin Author Harmonic Design

    (@harmonic_design)

    Can you confirm that you pasted ALL of the code in the correct place? I can confirm that the provided code 100% works. I’m thinking that you didn’t copy the entire code which would cause the critical error.

    Thread Starter Patrick

    (@pglad)

    I have copied all the code shown below into functions.php, but when the file is uploaded it generates a critical error. Have I missed something?

    function hdq_pglad_no_timer_first_q_paginate()
    {
    ?>
    <script>
    function hdq_pglad_no_timer_first_q_paginate(){
    let start = document.getElementsByClassName(“hdq_quiz_start”);
    console.log(start)
    if(start.length == 0){
    return;
    }

    start[0].addEventListener(“click”, function(){
    let results_wrapper = document.getElementsByClassName(“hdq_results_wrapper”)[0];
    let next_el = results_wrapper.nextSibling.nextSibling;
    if(next_el.classList.contains(“hdq_jPaginate”)){
    next_el.getElementsByClassName(“hdq_next_button”)[0].click();
    }
    });
    }
    setTimeout(function(){
    hdq_pglad_no_timer_first_q_paginate();
    }, 500); // create extra opportunity to load
    </script>
    <?
    }
    add_action(“hdq_after”, “hdq_pglad_no_timer_first_q_paginate”);

    Plugin Author Harmonic Design

    (@harmonic_design)

    That looks like all of it. This means that the issue is probably where you are adding the code. Your functions.php file might be weirdly formatted which would make adding any new code “finicky” in that it’s easier to place it in the wrong place.

    Please shoot me a message at harmonicdesign.ca. It’s probably easier to use email so that you don’t have to publically provide any site/theme information here.

    What I’ll do is modify the functions.php file for you so that you can just copy/paste the whole thing and ensure that it’ll be properly formatted ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Pass mark & pagination’ is closed to new replies.