I have created a view that lists all quizes. The view outputs the title of the quiz, plus some extra fields I have created for the quiz content type like tags, category, etc.

I would like to create a filter that allows the logged in user to filter by the various states/status (Not Started, In Progress, Finished) for the quiz. For each user, the above view should display their own state/status for each quiz. Attaching exported view for quick ref.

I am having trouble getting things to work, probably because I'm not understanding how some of the relationships work between quiz and quiz results.Can anyone walk me through how to setup this filter? Thanks!!!!

Comments

digitopo’s picture

anybody out there?

jphelan’s picture

Same here. I'd like a simple view of all available quizzes with that users state and score for each. Not understanding the relationships.

djdevin’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Full Views support is in 5.x.

nithinkolekar’s picture

Version: 7.x-4.x-dev » 7.x-5.0-alpha10
Status: Closed (outdated) » Active

with the quiz 7.x-5.0-alpha10(prod site) its not possible to get quiz status per logged in user. Changing status to active and also version.
@djdevin is there specific major version after which views full support works?

nithinkolekar’s picture

added related issue which was created by me for but 5.x dev version.

djdevin’s picture

Hi,

So there is no such status as "Not Started", so it will not be available in any capacity.

What you do have are the following statuses:

is_evaluated - this is 0 or 1, if the quiz is fully scored or not
time_start - this is always a date, this indicates the user clicked "start quiz"
time_end - this is always a date, or, a NULL value - this would indicate if the quiz was in progress, or finished

Let me know if that helps. All of the above should be available in views (on the "Quiz result" table)

nithinkolekar’s picture

I think is_evaluated is enough and my main concern which I described in other issue is that if Quiz is made to take only once user should known whether he already finished or not and sort quiz list accordingly.

I also tried complex way using views_conditional but I think that is not needed if Quiz supports this user-quiz one to one relation out of the box.
you can get more detail in other issue #2838111: quiz views - get field Evaluated value for current user

nithinkolekar’s picture

Version: 7.x-5.0-alpha10 » 7.x-5.x-dev
StatusFileSize
new31.37 KB
new27.75 KB
new4.69 KB

Just updated to 7.x-5.x-dev version and confirm that is_evaluated is not per logged in user instead its per quiz.

tried

1. contextual filter user - logged user

only lists the quiz per user finished/unfinished.

2. Relationships - Quiz result: Uid

No way , we can get is_evaluated(No if not started) only for current user. It lists all quiz with is_evaluated to true if it has taken atleast once by any one of the user.

attaching the screenshots and views export

djdevin’s picture

Not correct - is evaluated, time start, and time end, are all per attempt and not per quiz. This is so we can have multiple attempts per quiz per user.

If you want to pull attempts and get the evaluated status for the current user's attempts, use a Views argument to filter the "quiz result: uid"

You have to be able to handle multiple attempts, which is why it is not possible to simply say that a quiz has been graded for a specific user, unless you limit the attempts to 1 on the quiz.

Hope that helps

nithinkolekar’s picture

unless you limit the attempts to 1 on the quiz.

all the quizzes are has limit of 1 attempt only.

use a Views argument to filter the "quiz result: uid"

I tested that method too and that will limit the quizzes only those which are at quiz results table.

Evaluated
Uid\Quiz2 quiz1 quiz2 quiz3
2
true - true
3 no true -
4 - - -

for above table suppose quiz has only 1 attempt how we can get that per user? when I tested with above scenario

  • for uid 4 all with contextual filter no records is shown because there is no record for uid 4 in quiz results table.
  • for uid 3 only quiz1 and quiz2 status will be shown and he will not see quiz3 at all.

true : user already finished quiz.
no : user started quiz but not finished yet.
- : user is not attempted yet.

djdevin’s picture

Hi,

Try using "user" as a base table instead of "quiz results"

Since users do not have any attempts in the quiz results table, you can't use it as a base (as Views does not do RIGHT JOINs)

If you join from User to Quiz results on UID, then you would just have empty rows for users who haven't taken Quizzes.

You might need to do some extra work to do what you want - https://www.drupal.org/project/views_field_view might help as well.

This isn't really a Quiz issue though, and more of a "how do I do this with Views" question.

nithinkolekar’s picture

Issue summary: View changes
StatusFileSize
new7.21 KB

thanks @djdevin for your valuable info.

I ended up with using two different view blocks of content type Quiz with relationship Content: Quiz result. One block with contextual filter Quiz result: Uid and another with Quiz result: Uid with exclude option set to true.

One final question, is there a variable/table field somewhere for attempt count for quiz per user? Just looking for another possible way :).

djdevin’s picture

Absolutely!

For counts you should be able to use Views aggregation. You would probably create the same type of view (Users -> Quiz results) and then aggregate using a COUNT() on the is_evaluated column (or some other column). That should give you a User and Count. If you were to add the Quiz title then you would get the number of attempts by quiz.

steinmb’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.