Problem/Motivation

Entities are great. Quizzes are nodes, so this shouldn't be too big of a change but we will gain so much more functionality moving forward and will help us upgrade to D8. This is actually harder than the question types which are basically entities to begin with as they are rarely viewed outside the context of the Quiz engine.

Quizzes are not "content" and we should separate them from "nodes".

Proposed resolution

Migrate Quiz and related entities to Entity API classes and controllers.

Remaining tasks

1. Fully implement hook_entity_info for Quiz. Rely on EntityDefaultUIController.
2. Convert all db_** calls in quiz metadata storage to entity operations
3. Provide migration path from quiz nodes + fields -> quiz entities? OR: leave Quiz nodes with fields, and do entityreference to a Quiz.
4. Preserve current upgrade path from 7.x-4.x to 7.x-5.x
5. Preserve as much schema as possible.
6. Migrate/write new tests.

User interface changes

- How do we maintain Quiz appearing as content? Entity reference?
- Registration is a *really* good example of how to do this properly. See registration_menu() which puts local tasks on entity types with Registration references.
- Quiz field formatter which will mimic the behavior of 7.x-5.x
- Context is important - make sure user doesn't get lost in entityland. See Registration module.

API changes

Basically any node operations will be entity operations.

CommentFileSizeAuthor
#9 #1-2378365.png58.69 KBnithinkolekar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

djdevin’s picture

djdevin’s picture

Issue summary: View changes
djdevin’s picture

Issue summary: View changes
donapis’s picture

Hi,
The quiz version is now updated to version 7.x-5.1. Do you have roughly date of when the "multiple types of quizzes" features will be available?

nithinkolekar’s picture

Is that mean we can expect quiz<=>user will be entity referenced?
Tried very hard to get total quiz user had finished and got it with views having lot of relationships. Later found a module called Entity Reference Calc which works if entities are referenced.

Subscribing..

djdevin’s picture

Yes, it's pretty easy in 5.x right now anyway.

Just create a view based on Quiz results and create 1 relationship to the node and user.

You could probably use Views's built in aggregation.

nithinkolekar’s picture

#5 is not a requirement but just an example of how it could be easy if quiz<->quiz-result,quiz<->question-bank, user<->quiz-result is attached to each other via entity reference.

Just create a view based on Quiz results and create 1 relationship to the node and user

I did that already but found that for views which are required to generate charts/graphs involves different entities, it will make views more complex by adding multiple relationships which are not entity referenced.

currently planning to add two entity reference field to quiz-result namely quiz(node entity) and quiz-taker(user entity) and utilize modules like Entity Reference Calc,entity_backreference( useful for searching api indexing) and other related modules.

Is it very difficult to change internal structure of Quiz?

djdevin’s picture

it could be easy if quiz<->quiz-result,quiz<->question-bank, user<->quiz-result is attached to each other via entity reference.

I'm a little confused, how would that be easier? The relationships are already exposed in hook_entity_property_info() et. al

I think you are missing a critical table in your view called 'Quiz result answer' which stores the user's responses to individual questions on a result. If you build a View for charts/graphs it should not need the question bank at all.

We can generate charts and graphs just fine with the Entity relationships, with no entity references at all.

Quiz is complex but it's not too difficult to change the internal structure as it's mostly entity based but I'm a little confused as to why you'd need to do that.

nithinkolekar’s picture

FileSize
58.69 KB

If you build a View for charts/graphs it should not need the question bank at all

I mentioned quiz<->question-bank because with the current Entity relationships we can't get total questions in a quiz in views. This will be helpful to make listings of quiz with total questions in it to user before starting it.

for charts
To generate comparative charts for current-user results with other users, we need to have exact total no of quizzes each user had finished lets say 3 quizzes. To build this view users must have common quiz in between(comparative) and 4 relationships that makes views query execution slow with aggregation enabled(attaching the screenshot of views). In short we can avoid aggregation where ever possible. This can be done using Entity Reference Calc just by adding field of type entityreference_calc to Quiz-to get total questions, Quiz result-to get user's total attempt etc.

For that quiz relationships should be changed as Entity referenced so we could make use of all other modules that extends the functionality of entity reference.

djdevin’s picture

Okay, that seems like a really specific use case and should probably stay in a separate module. Entity reference calc is completely unmaintained so we can't add that as a dependency. I still do not see the benefit of Entity references for everyone. We use this for learning management and this issue has never come up.

Looking at your view I think there are some optimizations you can do to make it run faster. You should probably start with a "Quiz result" base table and then build your joins on that.

If you need to suggest Quiz core patches please open a new ticket.

steinmb’s picture

Hi
I have been going through a lot of support issues and bug report, trying to fully understand this task but it have proven to be a little difficult since I am lacking a deeper understanding of this module and it's history. It would be lovely if you found time to chime in on what the current state of this task is? I found these issues floating around, https://www.drupal.org/project/issues/search?issue_tags=7.x-5.1%20releas... . I guess all of these is still valid? The tag is outdated though.

djdevin’s picture

Version: 7.x-5.x-dev » 8.x-5.x-dev
Status: Active » Fixed

Fixed in the D8 Version. Quiz is a first class entity now.

Status: Fixed » Closed (fixed)

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