WordPress plugin customization: running an sql query upon button press

enter image description here

I’m trying to save user score attempts for this quiz plugin.
See http://learningbytes.co.uk/sample-test/ for example. After clicking on the finish quiz button (the value of which is “Finish Quiz”) I want to update the database and run the sql command below.

I noticed that it’s not a form, and I don’t think I will be able to use if(isset($_POST['Finish Quiz'])) to work around it.

I created a table in the database with columns: quiz_id,user_id,correct.

I want to run the sql command after the user pressed finish quiz button:

$sql = "INSERT into Table (quiz_id,user_id,correct) VALUES (1,1,$correct)"

Here is the php file that I think I need to edit:
https://ufile.io/6cbda (Notice that line 699) is what appears to be after the user clicks finish quiz but it’s not a variable $correct (It’s simply 0 staticly).

I planned to do the following:

1) Identify the variables (I think they are using js to update variables, which I have very little experience in)

2) Try to insert them after Finish Quiz if the user has an id.

I don’t really know which tags to put for this question, but could anyone point me in the direction to solve this problem?

Read more here: WordPress plugin customization: running an sql query upon button press

Leave a Reply

Your email address will not be published. Required fields are marked *