2

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?

2
  • I edit my answer with more information, take a look. Commented Aug 29, 2016 at 15:17
  • do you solve your problem? Commented Dec 16, 2016 at 19:02

1 Answer 1

1

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.

3
  • Poor user with uid=4, he only got a score of '0' ... But, much better answer now ... "my" only remaining curiousity now is "what's the vid about, whichs always seems to be equal to uid ...". Any, looks like I voted too early (I should have waited for this revision to show up ...) Commented Aug 29, 2016 at 15:03
  • @Pierre.Vriens I make other test and always the vid is equal to the uid, but I don't have time at this moment to look inside the module why. Commented Aug 29, 2016 at 15:08
  • good enough, I just checked quiz_schema, here is what it says about vid: "The current {quiz}.vid version identifier.". Whatever that "version" may be. Salut! Commented Aug 29, 2016 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.