How to know that the user has completed a quiz? Is there any function to pass the user id and the quiz node id and get true or false if the user has completed the quiz?

Or I have to write sql query for this?
With this query:

SELECT * FROM quiz_node_results n;


You can get all the information about the quizzes:

+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+
| result_id | nid | vid | uid | time_start | time_end   | released | score | is_invalid | is_evaluated | time_left |
+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+
|         1 |   1 |   1 |   1 | 1472154665 | 1472482124 |        0 |   100 |          0 |            1 |         0 |
+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+


Once you start a new quiz a new entry will be created in the table:

+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+
| result_id | nid | vid | uid | time_start | time_end   | released | score | is_invalid | is_evaluated | time_left |
+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+
|         1 |   1 |   1 |   1 | 1472154665 | 1472482124 |        0 |   100 |          0 |            1 |         0 |
|         2 |   1 |   4 |   4 | 1472482245 |          0 |        0 |     0 |          0 |            0 |         0 |
+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+


In this case the user with uid 4 has started at 1472482245 (time_start) the quiz with nid 1.

Once the user finish the quiz you will see a value in the time_end column, in this case 1472482657.

+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+
| result_id | nid | vid | uid | time_start | time_end   | released | score | is_invalid | is_evaluated | time_left |
+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+
|         1 |   1 |   1 |   1 | 1472154665 | 1472482124 |        0 |   100 |          0 |            1 |         0 |
|         2 |   1 |   4 |   4 | 1472482245 | 1472482657 |        0 |     0 |          0 |            1 |         0 |
+-----------+-----+-----+-----+------------+------------+----------+-------+------------+--------------+-----------+


And with this query:

SELECT n.pass_rate FROM quiz_node_properties n WHERE n.vid = 1;


You can get the pass rate (in this case for the vid 1)

+-----------+
| pass_rate |
+-----------+
|        75 |
+-----------+


So, if the score is lower than the pass_rate the user has not passed the quiz with the minimum of points required.