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
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | QuizView.jpg | 536.67 KB | edboost |
| #12 | quiz.views_.inc-1459358-12.patch | 5.46 KB | drewbe121212 |
| #9 | quiz.views_.inc-1459358.9.patch | 5.31 KB | drewbe121212 |
| #6 | quiz.views_default.inc-1459358.6.patch | 6.45 KB | drewbe121212 |
| #3 | quiz.views_default.inc_.patch | 19.16 KB | drewbe121212 |
Comments
Comment #1
drewbe121212 commentedOh 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?
Comment #2
drewbe121212 commentedOk, 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_nidThis 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_idRight 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.
Comment #3
drewbe121212 commentedOk, 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.
This patch also includes the patch applied @ #842958: quiz_node_results join to node
Comment #4
drewbe121212 commented^^
Comment #5
falcon commented7.x-5.x is not in use. Please re-roll the patch against 7.x-4.x
Comment #6
drewbe121212 commentedRerolled against 7.x-4.x
Comment #7
drewbe121212 commentedComment #8
kaizerking commentedAfter 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).
Comment #9
drewbe121212 commentedCleared bug, re-rolled patch. Also I introduced a lot of unneeded spaces in the previous patch. Cleaned those up.
Comment #10
edboost commenteddrewbe121212-
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!
Comment #11
edboost commentedComing 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!
Comment #12
drewbe121212 commentedHi 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.
Comment #13
falcon commentedHas anyone tested the last patch? I don't have the time to test it myself :/
Comment #14
edboost commentedFalcon,
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!
Comment #15
mpearrow commentedis there a version of this patch for 7.x-4.0-alpha9? This would solve the same problem for me -
thanks,
mjp
Comment #16
chiko.mukwenha commented@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.
Comment #17
edboost commentedWe'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.
Comment #18
chiko.mukwenha commentedAlright, 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.
Comment #19
drewbe121212 commented~ 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'.
Comment #20
chiko.mukwenha commented@mpearrow, I have alpha9, applied the patch and it worked.
@drewbe121212 thanks, will try that tonight!
Comment #21
mpearrow commenteddrewbe121212 and mukwenhac, thanks - the patch does indeed work against alpha9.
Best,
mjp
Comment #22
falcon commentedGreat, thanks!
Comment #23.0
(not verified) commentedspecificity