Hello,

I may be missing something here... but I have a content type 'modules'.

This content type has a node reference to quiz questions. This allows me to link specific pieces of content to a specific quiz question.

I am trying to write a view that gives me the output of the users quiz results with the associated question, as well as the associated module content.

I seem to be unable to make this happen. What do I need to do to get Quiz Questions and Quiz Results available in views to set relationships, fields etc? Right now, only 'quiz' is available (which provides quiz node NID, VID, and term ID). From the default quiz views, they have Quiz Questions, Quiz Results, quiz questions by results. What am I missing?

Thanks,
Drew

Comments

drewbe121212’s picture

Oh I see. It appears after looking in the code these views (the default quiz views) are the only ones capable of taking on this information.

Would it not be beneficial to provide all of the quiz items as handlers? That is... quiz questions, quiz results etc etc.

Also, I do not understand the Views API enough to fix this... but it looks like we have a bug involving quiz_views_handler_argument_quiz_nid.

I am getting error messages when trying to use this relationship...
Column not found: 1054 Unknown column 'quiz_node_relationship.vid' in 'on clause'

The class found in this file is completely empty. It looks like the node_relationship table got rid of this and replaced it with parent_vid?

drewbe121212’s picture

Category: support » bug
Priority: Normal » Critical

Ok, I have fixed up quiz.views.inc to be compadible with the new structure. A lot of the references did not account for vid > parent_vid and child_vid and nid > parent_nid and child_nid.

This is now fixed, however, I have one issue left. I will post up a patch once I am done.

Now the issue I am experiencing is that I cannot relate result answers to a specific result ID. When pulling the results answers it is pulling all answers, instead of those specific to the result ID being queried.

This stems from the views query builder doing this following:

LEFT JOIN {quiz_node_results_answers} quiz_node_results_answers ON quiz_node_relationship.child_nid = quiz_node_results_answers.question_nid

This actually needs to be:
LEFT JOIN {quiz_node_results_answers} quiz_node_results_answers ON quiz_node_relationship.child_nid = quiz_node_results_answers.question_nid AND quiz_node_results_answers.result_id = quiz_node_results.result_id

Right now when adding the field 'Result ID' or 'Is Correct' it does not allow me to add a relationship. What needs to be configured in the quiz.views.inc to make this happen? I tried specifying the following under 'is_correct', but it doesn't seem to be doing it.

     'relationship' => array(
        'handler' => 'views_handler_relationship',
        'base' => 'quiz_node_results',
        'field' => 'result_id',
        'base field' => 'result_id',
        'label' => t('Result'),
      ),
drewbe121212’s picture

StatusFileSize
new19.16 KB

Ok, I have finally dug in farther into this. Is there ever an instance where you would want the quiz_node_results_answers table to not include the link between the quiz_node_results.results_id table?

I added in the following to the quiz_node_results_answers table definition in views. I have also attached the patch to all o the updates made to 7.x-5.x views branch. This updates a lot of the structure updates that involved nid being changed to parent_nid and child_nid, and vid being changed to parent_vid and child_vid.

$data['quiz_node_results_answers'] = array(
    // Table Definition
    'table' => array(
      'group' => 'Quiz Results by Question',

      'join' => array(
        'quiz_node_properties' => array(
          'left_table' => 'quiz_node_relationship',
          'left_field' => 'child_nid',
          'field' => 'question_nid',
          'extra' => 'quiz_node_results_answers.result_id = quiz_node_results.result_id'
        ),
      ),
    ),

This patch also includes the patch applied @ #842958: quiz_node_results join to node

drewbe121212’s picture

Status: Active » Needs review

^^

falcon’s picture

Status: Needs review » Needs work

7.x-5.x is not in use. Please re-roll the patch against 7.x-4.x

drewbe121212’s picture

StatusFileSize
new6.45 KB

Rerolled against 7.x-4.x

drewbe121212’s picture

Version: 7.x-5.x-dev » 7.x-4.x-dev
Status: Needs work » Needs review
kaizerking’s picture

After applying the patch i got this notice :
Notice: Use of undefined constant is_correct - assumed 'is_correct' in quiz_views_data() (line 794 of /hsphere/local/home/---/----.com/sites/all/modules/quiz/includes/views/quiz.views.inc).

drewbe121212’s picture

StatusFileSize
new5.31 KB

Cleared bug, re-rolled patch. Also I introduced a lot of unneeded spaces in the previous patch. Cleaned those up.

edboost’s picture

drewbe121212-

This patch is great. I was trying to do the same thing and you totally solved my problem in a way that I could not have accomplished!

Thank you!

edboost’s picture

Coming back to my views (on another site on our multi-site installation), it looks like the tweaking I did with the patch removed "score" from my filter criteria in Views.

I won't display my code, because it's a total hack cut and paste job, but before committing this patch (which I hope Falcon will do), check out line 619 and make sure that line 619 includes the views_handler_filter_numeric for score.

Also possible I just made an error messing with the code or manually applying the patch. If so... sorry for adding confusion!

drewbe121212’s picture

StatusFileSize
new5.46 KB

Hi edboost,

I'm glad I could help out others and that what I did didn't introduce too many bugs :) I'm not sure how I managed that, but you are correct, the line went missing from my updates. After realizing that I was updating my dev server, while viewing my staging site and screaming to myself, why in the world is this not updating!!!... all is well in the world again. :) Patch updated, re-rolled against 7-x-4.x-dev.

falcon’s picture

Has anyone tested the last patch? I don't have the time to test it myself :/

edboost’s picture

Falcon,

I'm not a developer and I'm never sure what all goes into testing a patch.

BUT, in terms of the patch doing what it's supposed to do, without messing anything up on our site, the patch above works.

It allows us to create views that show quiz taker results by individual question. We're also using it to show file downloads of practice work that students need to do if they get a question wrong.

It's a great patch (for our purposes).

Sorry I'm slow -- I didn't realize how much I liked this patch until I overwrote it in the latest Quiz Module update. :)

Thanks drewbe and Falcon, I hope please let me know if there's anything a non-developer can do to help move this patch towards being committed.

Thanks!

mpearrow’s picture

Version: 7.x-4.x-dev » 7.x-4.0-alpha9

is there a version of this patch for 7.x-4.0-alpha9? This would solve the same problem for me -

thanks,

mjp

chiko.mukwenha’s picture

@Edbook and everyone, I have implemented the patch, but how exactly can we make use of its functionality, I'm a little lost there. Does it expose a view (visible when using the Views module) or what exactly.

I'm really keen to give it a go.

edboost’s picture

StatusFileSize
new536.67 KB

We've modified the view quiz_by_taker view that comes with quiz.

We have one view that shows results by quiz (when the quiz was taken, score, etc).

We have another view that adds the relationship with quiz questions, and then we can show quiz result by question (e.g., we have a math quiz, and the view shows a grid, each question has a line, an X if they got it wrong, a check if they got it right, then it states what kind of question it was (subtraction, fractions, etc)). It's great for directing students to other lessons they should review or other quizzes that they should take.

The patch doesn't really create the functionality, just clears up a little glitch in the code that was preventing the quiz question ID from work as a relationship (and perhaps in other ways too).

Here's a screenshot of our views page. Relationships on the right, and then content, with relationship, on left.

chiko.mukwenha’s picture

Alright, thanks for the great explanation.

I applied the patch and it seemed to work. My question is, how then can I change the view that comes up after someone has just finished a quiz?
As opposed to suggesting other quizzes to take, I would want to attach links to discussions about that question!

Hope that's possible. Thanks.

drewbe121212’s picture

~ mpearrow, does the patch not apply to the release you want? This would only be the case if something has changed along the way.

~mukwenhac, this can be done with a template.

Make sure -show feedback at the end of a quiz is checked under the taking options.
I believe the template you are looking for, and can place in your templates directory, is 'quiz-take-summary.tpl.php'.

chiko.mukwenha’s picture

@mpearrow, I have alpha9, applied the patch and it worked.

@drewbe121212 thanks, will try that tonight!

mpearrow’s picture

drewbe121212 and mukwenhac, thanks - the patch does indeed work against alpha9.

Best,

mjp

falcon’s picture

Priority: Critical » Major
Status: Needs review » Fixed

Great, thanks!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

specificity

  • Commit 5a33443 on 7.x-4.x, 7.x-5.x by falcon:
    Issue #1459358 by drewbe121212: Several problems with the quiz views...

  • Commit 5a33443 on 7.x-4.x, 7.x-5.x, quiz-pages by falcon:
    Issue #1459358 by drewbe121212: Several problems with the quiz views...

  • Commit 5a33443 on 7.x-4.x, 7.x-5.x, quiz-pages, 2269219 by falcon:
    Issue #1459358 by drewbe121212: Several problems with the quiz views...

  • Commit 5a33443 on 7.x-4.x, 7.x-5.x, 2269219 by falcon:
    Issue #1459358 by drewbe121212: Several problems with the quiz views...