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?

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.

| improve this answer | |
  • 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 ...) – Pierre.Vriens Aug 29 '16 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. – Adrian Cid Almaguer Aug 29 '16 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! – Pierre.Vriens Aug 29 '16 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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