OK, so these edits will do what you need to do, but there are two things to be aware of.
1) This will not work for the “select all that apply” question type. This solution would need to be extended to allow for that.
2) This will not mark (visually highlight) which questions and answers were right or wrong – although I added in the skeleton on how to get that data so that you can add this in if you want.
STEPS.
First, let’s change the plugin version so that my future releases don’t overwrite your changes.
Edit the plugin’s index.php
and change the version number to something like 99.9.9
. Change on both lines 8 and 19.
– – – – –
Now we need to edit the question templates to stop the data from printing on the page. Luckily this is very easy for all question types.
under ./incliudes/templates
you will see each of the template files. Edit each of them. the default.php
(default multiple choice), change line 14
to se $selected
to 0. Do the same for image.php
. For text.php
, change line 28
to set $correct
to an empty string ""
.
That’s it!
– – – – –
Now we need to edit the main script file. ./includes/js/hdq_script.js
. We are looking for the submit
function (starts line 628
). Replace the entire function with the following: https://pastebin.com/raw/7CFQbPeY
This stops HD Quiz from doing the normal submit stuff and instead creates a data array of the question id and the selected answer and sends it to the backend for validation. It then receives a new array from the backend, which we use to calculate the score and then continue to do the other HD Quiz stuff like show the results.
– – – –
Finally, we add a new function to the backend that validates the submitted questions and answers. Add the following function to the index.php
file of the plugin at the very end of the file. https://pastebin.com/raw/UyVuKn7q
– – – –
and that’s it!