I am trying to put together a view showing all the quizes assigned to particular course (og group node)...which works except if I add quiz close time I get multiple rows for one of the quizes. Setting DISTINCT on the query did not remove the duplicates...what I found was that this was happening because I have two revisions of the course with difference closing times - so both satisfy the query criteria.

I then added the filer Quiz:Quiz Version = latest, which I thought would fix it. Intead, I got a lot of errors. Here is the query which is generated:

SELECT DISTINCT node.title AS node_title, node.nid AS nid, node.language AS node_language, quiz_node_properties.quiz_open AS quiz_node_properties_quiz_open
FROM 
{node} node
INNER JOIN {quiz_node_properties} quiz_node_properties ON node.nid = quiz_node_properties.nid
WHERE (( (. = 'SELECT MAX(__subselect.) FROM {} __subselect WHERE __subselect. = . AND __subselect. = .') AND (( (node.status = '1') AND (node.type IN  ('quiz')) AND (node.language IN  ('en')) )))
ORDER BY node_title ASC

The errors in the logs are as follows:
Notice: Undefined index: secondaries in quiz_views_handler_filter_quiz_nid->query() (line 102 of /var/www/lms/sites/all/modules/quiz/includes/views/handlers/quiz_views_handler_filter_quiz_nid.inc).
Warning: Invalid argument supplied for foreach() in quiz_views_handler_filter_quiz_nid->query() (line 102 of /var/www/lms/sites/all/modules/quiz/includes/views/handlers/quiz_views_handler_filter_quiz_nid.inc).
Notice: Undefined property: quiz_views_handler_filter_quiz_nid::$secondary_vid in quiz_views_handler_filter_quiz_nid->query() (line 120 of /var/www/lms/sites/all/modules/quiz/includes/views/handlers/quiz_views_handler_filter_quiz_nid.inc).
etc...

Seems that they stem from the $this->options['secondaries'] not working on line 102. dpm($this->options) verifies that secondaries is not part of the index. Will keep looking but any help on this is greatly appreciated.

Comments

pbonnefoi’s picture

Getting the same error with Quiz 6.x-4.4 Subscribing.

pbonnefoi’s picture

I was able to fix my problem by choosing views type "quiz" when creating the view instead of "node". The problem is, you'll be limited when choosing fields to display. My solution isn't the best but worked for me. Just remember I'm using the 6.x-4.4 version of Quiz.

mpearrow’s picture

Same behavior in 7.x-4.0-alpha9.

charliekwin’s picture

I've been beating my head against this intermittently as well. I haven't come across a fix yet, and am not smart enough to come up with a "proper" solution, but was able to bodge something together based on a patch that was posted for the Revisioning module (http://drupal.org/node/975492#comment-5081046). Here's my approach, in the hopes it'll help someone else...

Edit the quiz/includes/views/handlers/quiz_views_handler_filter_quiz_nid.inc file at line 120 as follows:

<?php
    //Old code
    //$this->query->add_where(0, "$this->secondary_table_alias.$this->secondary_vid", $this->subselect());
    
    //New code
    $max_vid_subquery = "SELECT MAX(vid) FROM quiz_node_properties WHERE quiz_node_properties.nid = node_quiz_node_properties.nid";
    $where_clause = "quiz_node_properties.vid = ($max_vid_subquery)";
    $this->query->add_where_expression($this->options['group'], $where_clause);
?>

Works for me on views that have the type "quiz" as long as it contains the Quiz NID relationship.

ETA: wrong filename.

falcon’s picture

Priority: Major » Minor
A Romka’s picture

#4 worked for me! thanks!

elBradford’s picture

#4 worked for me as well.

UPDATE: Actually, I still get duplicates when I add a field that has different values across revisions.

djdevin’s picture

Status: Active » Closed (outdated)

This issue is being closed because it was filed against a version that is no longer supported. If the issue still persists in the latest version of Quiz, please open a new issue.