About the display of the right and wrong questions after submit
-
Hi there..!
Is there any way that when one submits the test it should be written on top or bottom of every question that whether it was Right, Wrong or Skipped..? As now only red and green background indicates that it was Right or Wrong. In this process a person doesn’t know which questions he skipped. Therefore, I want to show users in written that question was right, wrong or skipped.
Regards,
Agha
-
Hi mubasher99,
there is already a visual difference between “you got the answer right” and “you didn’t answer, but here is the correct one”.If the user gets the question right, then the entire answer gets a green border. If the user did not get the question right and you have the “show which answer was right” option enabled, then the correct answer just gets a green underline.
One thing you can try (as this is entirely subjective) is to remove the light green background, only showing the borders. This should make the difference between green borders or just green underline more visually obvious.
This can be done by adding the following CSS to your theme’s style sheet.
.hdq_correct, .hdq_correct_not_selected { background: transparent !important; }
You can also play around with the above to maybe something like this.
.hdq_correct_not_selected { background: rgba(255, 129, 0, 0.15) !important; }
That will make it so that the correct answer that wasn’t selected gets a light orange colour.
If none of the above work for you, then this is still possible but would require some custom JS
So that cant be shown in words that which question was right, wrong or skipped..?
or do you know any way to do it for me..??It would be possible to add words but would require custom JS. Unfortunately, this isn’t something I can just quickly write for you, but I will try and take a crack at it this weekend if I have time.
The custom solution I provided in your previous support question would include the brunt work for something like this too. Basically, I will edit the
function hdq_custom_submit()
function provided in that previous thread to also check each question for answers that include a classhdq_correct_not_selected
. If the class is found, then we can append some text such as “This question was skipped” to the question title.Thank you very much for being supportive and informative always.. 🙂
Please give it a try if you find time on weekend.Hello, sir please help me, In my website the quiz is not displaying the result. It was working fine, but now it’s not showing the result. I have only wp total cache plugin to minify js and all. so I inactive that plugin, but still it’s not working. May I know the reason why it’s not showing the result.
@aswiniravella This thread is for a different user with a different request.
Please start a new support thread and include a link to one of your quizzes. I’m sure I’ll be able to get this sorted for you 🙂
@mubasher99 Good news incoming soon!
Hello Mubasher99,
here you go friend 🙂The first thing to do is download the beta (you are my first guineapig) of the new version of HD Quiz. Other than some minor bug fixes and enhancements, the main point of this version is that comes with custom actions and hooks, allow you or any developer to hook into the functionality of HD Quiz. With this, other developers can even code their own addon plugins for HD Quiz!
Using these new actions, we will be extending HD Quiz for your own needs.
First, deactivate HD Quiz and delete it (you won’t lose any data), then upload and active this new beta version.
Next, we add our custom code to your theme’s
functions.php
file to extend HD Quiz in the way that you need. NOTE: It is always recommended to make a back up of your functions.php file before editing it!Copy and paste the following code to the top of the functions.php file.
function hdq_before_test($quizID) { ?> <script> function hdq_custom_submit(){ let data = {}; // 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; let d = '<p>Total correct answers= <strong>'+c+'</strong><br/>\ Total Wrong Answers= <strong>'+t+'</strong><br/>\ Total percentage= <strong>'+p.toFixed(2)+'</strong><br/>%</p>'; jQuery(".hdq_results_inner .hdq_result").html(d); // 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_not_selected"); if(sel.length > 0){ data = "No answer selected"; } else { sel = jQuery(this).find(".hdq_correct"); if(sel.length > 0){ data = "Correct answer"; } else { data = "Incorrect answer"; } } } jQuery("<h2>" + data +"</h2>").prependTo(this); }); return JSON.stringify(data); // expects a json string to be returned } </script> <?php } add_action('hdq_before', 'hdq_before_test'); function hdq_submit($quizOptions) { $quizOptions->hdq_submit = "hdq_custom_submit"; return $quizOptions; } add_action('hdq_submit', 'hdq_submit');
The fist function
hdq_before_test
allows us to add any code we want to the page. In our case, we are adding some custom Javascript.The second function
hdq_submit
tells HD Quiz to do two things once a quiz has been submitted. First, it will check to see if there is a javascript function calledhdq_custom_submit
and runs it if there is. This is the name of the javascript function we added inhdq_before_test
. The second thing it does is sends the result of that function toadmin-ajax.php
(which is WordPress’ ajax file and can be used to do things like send emails or save results), but since we are not using that, we are just ignoring it.I’ve tested the above code myself with great success, so it should work for you. Just note that you may want to edit it a bit to rename some of the strings to reflect what you want instead of the generic strings I used such as “Incorrect answer” and stuff.
Let me know what you think!
- This reply was modified 4 years, 7 months ago by Harmonic Design. Reason: fixed code formatting
- The topic ‘About the display of the right and wrong questions after submit’ is closed to new replies.