• Resolved mubasher99

    (@mubasher99)


    Hello there..!
    I am eager to upload the code that you wrote for me in the link i have mentioned. but i am afraid because for that i will have to delete the Plugin and reinstall the beta version. Will that remove my data?
    please guide me to update my HDQ plugin. My Website is live now and HDQ is the main feature of it (Thanks to you for such a amazing Plugin). The only fear i have is uninstalling it would deprive me of my months of hard work.
    PS. i have also uploaded few of other codes you wrote for me in my function.php file. what happens to them if i shift to the beta version?

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

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

    (@harmonic_design)

    Hi mubasher99,
    do NOT replace HD Quiz with that beta version. That version is ~6 months old! If you have not already, you can safely update to the latest version of HD Quiz 1.7.0.

    HD Quiz does NOT delete or remove any data when you deactivate it, so you’re completely safe!

    functions.php is a theme file, not a plugin file. Whenever you update a plugin, the old version gets completely overwritten with the new version, meaning any changes you made to the plugin files directly will no longer exist.

    Because I got you to add the custom code to functions.php, that custom code will remain even after updating the plugin; so no issues there either ??

    Thread Starter mubasher99

    (@mubasher99)

    But i am using the latest version of HDQ and pasted the code in function.php file its not working. thats why i thought it might work if i upload that beta version.
    can you please tell me if the code is still applicable to this version i am using or there might be any other fault

    Plugin Author Harmonic Design

    (@harmonic_design)

    please show me a link to a quiz and I’ll take a look

    Thread Starter mubasher99

    (@mubasher99)

    https://mastermcqs.com/online-test/

    here is the link for all my online quizzes. All i want is to change the Result Display.
    Instead of showing result like:
    1 / 20 – 5%
    i want to show it:
    Total Correct Answers= 1
    Total Wrong Answers= 20
    Total Skipped Questions= 7
    Total Percentage= 5%

    Thread Starter mubasher99

    (@mubasher99)

    Moreover as the test starts a <div> for “Result of the Test” appears for a second and vanishes. Is there any fix for it??

    Plugin Author Harmonic Design

    (@harmonic_design)

    OK, so one of the reasons was that the code I have you all those months ago was for the original beta version – the version that first introduced hooks and actions to HD Quiz. However, these hooks need to be called a little bit differently in the live version.

    I also updated the JavaScript code to be a bit nicer too ??

    Please replace that old code with the following. This has been fully tested and confirmed working in the latest version of HD Quiz (and will work for all future versions too!).

    However, I noticed some other discrepancies with your site and HD Quiz. For example, the change I noticed in how the functions get called from the beta to the latest version of HD Quiz would only affect when the function is called – but I don’t see the function on your site anywhere :S

    Please replace the old code with this in your functions.php file and check to see if it works now. If it is not working then it means that there is a different issue such as page caching or maybe a child theme.

    function hdq_before_mubasher99($quizID)
    {
        ?>
        <script>
    	function hdq_custom_submit(){
    		let data = {};
    		let no_answers = 0;
    		
    		// mark each question with string on whether answer was right, wrong, or unanswered
    		jQuery("#hdq_<?php echo $quizID; ?> .hdq_question").each(function(){
    			let data = "";
    			if(!this.classList.contains("hdq_question_title") && !this.classList.contains("hdq_results_wrapper")){
    				let sel = jQuery(this).find(".hdq_correct");
    				if(sel.length > 0){
    					data = "Correct answer";
    				} else {
    					sel = jQuery(this).find(".hdq_wrong");
    					if(sel.length > 0){
    						data = "Incorrect answer";
    					} else {
    						data = "No answer selected";
    						no_answers ++;
    					}
    				}				
    			}
    
    			jQuery("<h2>" + data +"</h2>").prependTo(this);
    		});
    		
    		// hdq_score is array of score (score/total questions)
            let c = hdq_score[0];
            let t = hdq_score[1];
            let p = (parseFloat(c) / parseFloat(t)) * 100;
    		p = p.toFixed(2);
            let d = 

    <p>Total correct answers: ${c}<br/>
    Total Wrong Answers: ${t}<br/>
    Total Skipped Questions: ${no_answers}<br/>
    Total percentage: ${p}%
    </p>`;
    let results_section = document.querySelectorAll(“.hdq_share”)[0];
    results_section.insertAdjacentHTML(“beforebegin”, d);
    return JSON.stringify(data); // expects a json string to be returned
    }
    </script>
    <?php
    }
    add_action(‘hdq_before’, ‘hdq_before_mubasher99’);

    function hdq_submit_mubasher99($quizOptions)
    {
    array_push($quizOptions->hdq_submit, “hdq_custom_submit”);
    return $quizOptions;
    }
    add_action(‘hdq_submit’, ‘hdq_submit_mubasher99’);`

    Plugin Author Harmonic Design

    (@harmonic_design)

    Whoops. Forgot that the WordPress forum uses the backtick to format code, so it looks broken in my last reply.

    here is the full code as an easy copy/paste https://pastebin.com/raw/6KWT4q3W

    Thread Starter mubasher99

    (@mubasher99)

    I have pasted the above code in function.php and nothing worked for me..
    I think you are right there might be any issue. if you dont mind can you please send me your email i can send you admin login to check it yourself..?

    Plugin Author Harmonic Design

    (@harmonic_design)

    Sure. please contact me at harmonicdesign.ca and I’ll take a look!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘will shifting to Beta Version lose my data’ is closed to new replies.