Hello quiz-users and quiz-developers,
I had to make a new ajax_quiz module for my client, which I want to give back to the community. For a preview I attach a version which shall work with quiz-6.x-4.0-beta3.
Please test whether it works in your environment and give me feedback what needs to be done to make it useful for more and more people.
First known issue:
It does not work with quiz-6.x-4.0-dev as of right now, because it seems to be a "moving target". For this I have to familiarize with quiz-6.x-4.0-dev a little bit more in order to guess in which direction this target is moving... ;-)
Comments
Comment #1
falcon commentedWhere is the attachment?
Comment #2
raphaelhuefner commentedOh, sorry, the attachment apparently went away when I was trying to edit the list of "known issues". Here it is again.
Comment #3
raphaelhuefner commentedPlease bear with me, it's the first time I do such stuff. So, honestly, I didn't watch out for disappearing attachments ;-)
Comment #4
falcon commentedHi!
I just had a brief look. I will have a closer look later when the module is working with 4.x-dev.
It seems it will degrade gracefully. Great! The code also looks good. I haven't studied it, just read brifly through it. I noticed a couple of things:
Line 34: Please use 'access quiz'. access content is in many ways correct, but we require that users have access quiz permission as well in order to take a quiz.
Line 122: We should try to find a faster way, although this one was quite creative :) If I were to write quiz from scratch I would probably make the quiz node available through a global variable. Maybe we should pass the nid in the url and get it from there? I guess arg(1) won't give you the nid at the moment... Or we make sure that it is to be found in the form state...
Also we try not to depend on to many modules. If you are able to remove the ajax_load dependency that would be great!
It would be good if you are able to make the module work with 4.x-dev! My employer don't want me to spend time on ajaxifying quiz, but if you are able to make it work I can make sure it continues to work with its "moving target" :)
Comment #5
raphaelhuefner commentedThis is the next version, which should work with a CVS checkout of quiz-6.x-4.0-dev. I did as described here: http://drupal.org/node/26481/cvs-instructions/DRUPAL-6--4
For comments, see next comment. (I don't wanna loose that file again ;-)
Comment #6
raphaelhuefner commented"Line 34": it now uses 'access quiz' permission.
"Line 122": will be solved after you saw it working. ;-)
Using arg(1) for fetching the quiz nid would work if you display the quiz as a stand-alone main page content, but not inside of views and panels (which have other URLs, of course). But quiz-inside-views&panels is the reason why you would ajaxify quiz in the first place: in order to display it beside other content which shall not go away on a page refresh. Or, as it is the case with my client, the other content can not re-appear on page reload, because it is also ajaxified stuff.
So from the point of view of AJAX, I think it is not a good thing to make quiz more and more dependent on the URL, as it happened at least in 3 ways I know of currently:
* by making quiz taking a
MENU_LOCAL_TASK(I had to work around that by starting to use a customizedtemplate_preprocess_views_view_row_node().)* by using
menu_get_object(), at least in "quiz taking" contexts (This one I also solved in the customizedtemplate_preprocess_views_view_row_node().)* by letting
_quiz_is_taking_context()do a comparison forarg(2) == 'take'as of the current 4.0-dev version. I think I will achieve to fool evenarg(2)into thinking the "right" thing, but "fooling" is not a clean concept to be easily understood by fellow developers. BTW, the old_quiz_is_taking_context()"just worked".Just for the record, here is my customized
template_preprocess_views_view_row_node():[thinking pause ...] Ha! Got it! If I will be able to "fool"
arg(2), we also can usearg(1)instead of "Line 122".But honestly, I'd *love* to get rid of the customized
template_preprocess_views_view_row_node(), because I think this will be an entry barrier for other users who wish to ajaxify their quizzes.Regarding the dependency on "ajax_load": getting rid of this dependency essentially means duplicating "ajax_load"s code, which I'm only reluctant to do: http://en.wikipedia.org/wiki/DRY But if you request so, I will do it. Maybe I get around to conditionally use either my integrated duplicate or another "ajax_load", if installed and of a superior version. I believe most AJAX-heavy users will have "ajax_load" installed, anyway.
Regards,
raphaelhuefner
Comment #7
falcon commentedI see. I have very little experience with views and panels. The possibility of using quiz the way you are haven't struck my mind at all. I would use ajax_quiz to slightly improve performance and ux.
The way I see it there are two main problems requiring a _preprocess_views_view_row_node(&$vars):
1. node_view isn't where you take the quiz anymore.
-- Possible solution: Ajaxify what happens when the users pushes the start button on the node_view?
2. the use of menu_get_object and arg(2) to determine "quiz context".
-- Possible solution: Make sure $node is passed to every function and object who needs it so that they won't have to fetch it from the menu rooter. This would also make quiz a tiny bit faster. We could also insert $quiz_node->quiz_context to replace arg(2)
Does the possible solutions sound reasonable to you? Maybe there are better ways/best practices for doing this?
Comment #8
falcon commentedAbout the "dry" stuff. I absolutely agree, but I think it applies best for organizations/programmers who are in control of all the code. In many ways ajax_load is third party software for us. There is a forest of ajax modules out there. I don't know how well each of them work, if there are compatibility issues and the likes. My plan is to include your ajax_quiz code in the main quiz module if we can make it work. I'm a bit reluctant to force everyone who uses quiz to use ajax_load as well.
Comment #9
raphaelhuefner commentedLOL! The thought of "[DRY] applies best for organizations/programmers who are in control of all the[ir] code" and the words "third party software" struck a bell: One also could interpret DRY as "Don't repeat *yourself* ... but most certainly *do* repeat others!" Strikingly logical, isn't it? :-D
Well, ice broken. I'll try to integrate it. Even if it's only for the fun of playing on words ... ;-)
Comment #10
raphaelhuefner commentedRegarding #7, point 1: This sounds very good, I will try that. Most of my client's quizzes have introductory texts anyway and I can even think of automatically submitting the "Start"-button if the module user wishes to bypass such "introductory texts". If I am right, this could get us rid of the
_preprocess_views_view_row_node(&$vars)entirely. (It seems I kept on ajaxifying the "Start"-button out of my sight and therefore out of my mind. Thanks for re"mind"ing me. ;-)@ Point 2: To me, this sounds like a major restructuring, which could get in the way of your plans for the next 4.0-rcX. I would suggest postponing that to maybe 4.1 or so. But I'd like to keep having it considered for the future. For the time being, I would go with "fooling" just to get 4.0 out of the door soon. (My next "attack vector" is replacing
$_GET['q']with"node/123/take"just before callingquiz_take()and reverting it back just in the next line after calling. I hope it works.)Regards,
raphaelhuefner
Comment #11
falcon commentedRe #9:
Good :) (The code isn't repeated unless our users already have it installed. We're just taking the things we need from that module and customizing it to fit quiz perfectly. I think our users will appreciate it. :) )
Re 10#:
@ Point 1:
Yeah, getting rid of _preprocess_views_view_row_node(&$vars) would be great!
@ Point 2:
I will have a brief look at this issue later. I don't think it will be that big a change, we'll see. We have to solve this one to if we are to get rid of _preprocess_views_view_row_node(&$vars) I think?
Comment #12
falcon commentedHi!
I got this error message when trying to take a quiz the normal way(without views and panels). (I just updated my quiz project from cvs.)
"Firefox has detected that the server is redirecting the request for this address in a way that will never complete."
Maybe it only works when quiz is taken in a view or a panel?
(I did empty cache, and also emptied my browser cache, cookies and everything. And I made sure everything was back to normal after disabling ajax_quiz_vc)
Comment #13
raphaelhuefner commented@ Point 2: No, it should not be necessary to solve this to get rid of
_preprocess_views_view_row_node(&$vars), if I'm not completely mistaken about what I learned about Drupal so far. But I'm still prone to the occasional surprise.Concerning "ajax_load": We will grok the whole module, not only , just because we need the whole module. It does only this one thing, in the best way I know of so far. It doesn't do anything else we could leave out from integration. And customizing amounts only to renaming all the module functions in order to avoid namespace conflicts, just in case the user has the "original" installed.
One more thing, not every quiz user would depend on it, only users who want to ajaxify their quizzes. It's the same as with the other quiz dependencies: For example, as long as I don't wish to do quiz statistics, I won't need "chart".
BTW, I will be "away from keyboard" from 5th of February until 20th of February. Let's see if I get it working before!
Comment #14
raphaelhuefner commented@ #12: I did my 4.0-dev version without views or panels, just for you to see it working. Well, epic FAIL. Lets see how I get to reproduce this error.
One first idea for solving: Please disable ajax_quiz_vc before going from ajax_quiz_vc-6.x-4.0-beta3 to ajax_quiz_vc-6.x-4.0-dev and then re-enable the module, because I did change the path of the MENU_CALLBACK to match that arg(2). I believe Drupal caches the menu paths? In my understanding, hook_menu() is only executed on enabling a module, is this correct?
Comment #15
falcon commentedI think our goal should be to make your ajax quiz the defualt way to take a quiz. It won't be an extra module. Instead all your code will be included in the main quiz module files. This is off course given that it degrades gracefully... What do you think about this? I mean I see no reason not to do it. And I see many reason to do it:
- Easier to maintain
- Slight performance increase
- Fewer modules to think about for us and for our users.
It is fine by me to depend on ajax_load. The issue list and maintainers of that module suggests that it is reliable. If mbutcher objects we have to include the ajax_load code in quiz later.
Comment #16
falcon commentedRe #14: I did the install on a different computer. The beta3 version has never touched this one :)
BTW: Empty cache rebuilds the meny rooter as well, and you can rebuild only the menu rooter using the devel module. In addition I think it can be rebuilt from somewhere in the admin section as well.
I will try to test the ajax qui module some more to see if I can provide you with some more info.
Comment #17
falcon commentedI'm sorry, it was working after all. And when I disabled js it degraded gracefully. GREAT JOB!
I have generated 5 000 nodes using devel. Some of them has the bug described above. Some of them haven't. I tested with your module on a node with the bug and tested without your module on a node that was working... I though I was using the same node because I used the top node in my content list. The problem is that the nodes in the content list are in random order when they have the same timestamp... :/
I found another bug though. If you have a quiz direction in your quiz the user will be returned to the first question when pushing next on the direction. He also gets the error msg "You must provide an answer". If you disable js the problem goes away.
Comment #18
raphaelhuefner commentedRe #15: Now I got it, finally. "main quiz module" is not the "quiz module suite". I'll see into integrating, but first things first: You didn't see ajax_quiz_vc working once yet, right? This still nags me most.
Re #16: I'm eager to know which URL it is redirecting to, is it "/node/123/take" or "/node/123/take/ajax"? And is this redirecting error happening to the main page or to the AJAX request? For AJAX and JS development, I almost always have to rely on http://getfirebug.com/ to see "whats really happening".
Comment #19
falcon commentedJust to be clear: The bug described in #12 has nothing to do with your module. It is a bug in quiz or perhaps devel.
I use firebug. It makes my work a lot simpler :)
Comment #20
falcon commentedIs it possible that it looses the quiz taking session?
I have a quiz with 3 multichoice questions. Skipping is allowed but not used.
This happens:
0. Press take - works
1. Press next on the first question - works
2. Press next on the secont question - doesn't work
3. repeat 2 - works
4. press next on the third question - works
5. press take tab - question 2 is loaded instead of question one.
6. Press next on the second question - works
7. Press next on the third question - doesn't work
8. press next on the third question - works
9. Jump to 0...
Comment #21
raphaelhuefner commentedHere is version 4.0-dev1 [sic!]
Comment #22
raphaelhuefner commentedPlease disable the module before update, and re-enable it after update, since I changed the MENU_CALLBACK path again.
4.0-dev1 does not yet address #20 or #17, but finally I got rid of
_preprocess_views_view_row_node(&$vars)and ofdebug_backtrace(). Phew!It shall work in direkt node_view and inside panels&views, too.
Just press "Start Quiz".
Comment #23
raphaelhuefner commentedI just updated from CVS DRUPAL-6--4, and there seems to be something wrong with all those menu_get_object('quiz_type_access')-calls inside quiz, they return NULL instead of the quiz node, even if I disable ajax_quiz_vc. When I dump the menu router item returned by menu_get_item() under path "node/123/take", it has no "quiz_type_access_load" in its "load_functions"-array.
I believe this is a bug inside of quiz, because one symptom of this is a missing "Back"-button, even in non-AJAX (disabled ajax_quiz_vc) quiz taking. This can be seen in quiz_question.module @ line 168:
This menu_get_object('quiz_type_access')-call returns NULL and thus no Back-button gets rendered.
Shall I open a new issue for that?
Regards,
raphaelhuefner
Comment #24
raphaelhuefner commentedRe #23: I opened a new issue: #703682: menu_get_object('quiz_type_access') returns NULL on paths like "/node/123/take"
I can make the Back-button re-appear by manipulating my fake menu router item like this:
Regards,
raphaelhuefner
Comment #25
raphaelhuefner commentedRe #17 and #20: I tried to reproduce both, #17 "jumping back to square one after quiz direction" and #20 "take tab confusion", but to no avail. Would you mind sending me a complete code-dump and a complete DB-dump (via
mysqldump -h127.0.0.1 -P3306 -udbuser -pdbpass dbname --default-character-set=utf8 --no-create-db --routines --triggers | bzip2 > export.sql.bz2) of a setup where these errors occur at your site?Regards,
raphaelhuefner
Comment #26
raphaelhuefner commentedI'm away from keyboard until 20th of February. So long, good luck!
Comment #27
falcon commentedI did a new test today. The basics seems to work fine!
#17 "jumping back to square one after quiz direction" seems to be gone. Maybe the new version of quiz or the new version of ajax quiz have fixed it?
Still to do:
#20: Stability issues. If I take a quiz with multichoice questions multiple times I sometimes have to press next twice on some questions. It appears to happen randomly... (These are the issues we love... :/)
New: Answers aren't remembered when you move back and forth between questions.
New: Messages that are set when you push the take tab will stay there throughout the quiz. For instance the message "You have already passed this Quiz."
I'm reluctant to send my files and db. Both have information I don't want to give away.
Comment #28
falcon commentedComment #29
falcon commentedHi @raphaelhuefner,
Are you making any progress?
Comment #30
raphaelhuefner commentedHi @falcon,
sorry for being late, I was busy getting the back-log done which accumulated during my vacation.
As for the progress: I need your cooperation to reproduce the bugs you mentioned in #27. I do not achieve to reproduce them on my own.
The only idea I have so far is to give you the code-dump and DB-dump of my ajax_quiz_vc-testbed (pretty much only a clean Drupal 6.15 with current versions of the modules ajax_load, ajax_quiz_vc, autoload, ctools, panels, quiz-6.x-4.0-dev [recent CVS checkout] and views), and you "install the bugs" and send it back to me.
I will set up a public installation of this testbed and post the URL here.
Comment #31
raphaelhuefner commentedThe testbed installation can be found here:
http://ajax.quiz.drupal.raphaelhuefner.com/
user: admin
pass: ajax_quiz_vc2010
code-dump:
http://ajax.quiz.drupal.raphaelhuefner.com/sites/default/files/aqtest.tgz
DB-dump:
http://ajax.quiz.drupal.raphaelhuefner.com/sites/default/files/aqtest.sq...
Comment #32
falcon commentedI'm sorry for my late reply. I have been on vacation.
I think this one will have to wait for 5.x now. We're trying to finish 4.x asap. There will be ajax in 5.x(or 4.1), and I think your ajax quiz module will do the trick!
Comment #33
raphaelhuefner commentedOK, let's put this on hold until after finishing 4.0.
For the record while being "on hold": I'm still stumped on how to reproduce the bugs described in #20 and #27, so I take the liberty to set this issue back to "needs review", hoping to get input from somebody else, as I guess that you might be too busy as the quiz module maintainer, now, especially during 4.0 release preparations.
Comment #34
raphaelhuefner commentedBug fix: Avoid to call drupal_add_js($settings, 'setting') twice, as the duplicated data would get merged into an array instead of overwriting the data of the first call. Effect: The throbber shows up again.
Comment #35
ClearXS commentedPlease revise everything again for XML Parsing Error: "not well formed" and for errors on the admins block page and blocks not showing up or incorrectly:
http://drupal.org/node/809244#comment-3027958
It seems similar errors have been going on for a long time in several releases, so there seems to be some danger baked into this module and sub modules that theoretically can be released again on every module change? -and the problems are with the latest official 6.3.5 release.
Seamonkey also is more sensitive and only show xml parsing error, while IE shows the page but with left and right columns disappeared and block errors.
If someone wants to experiment these new versions with my Tendu theme that is a little changed, or even with my huge modules list and possible interactions:
http://cxs2.info/download/Drupal_Tendu_style.css.tar.gz (changed style.css file in Tendu 6.x-2.x-dev theme module)
http://cxs2.info/download/all.tar.bz2 52.62 MB - 28 de Mayo 2010 (.../sites/all directory with all modules, themes, libraries, plugins)
P.S.: I'm very happy to try the new releases, once its pretty sure that these errors are unlikely to happen anymore. I'm eager to incorporate this advanced module into my install, but I have had my portion for the moment loosing a life (but yet quiet and few articles) website and more problems.
Comment #36
ClearXS commentedThe error might arise with the JQuery Menu module that is necessary for Advanced Books and Advanced Forums (with one of the browsers, logged in or out). The developer says that often other modules are not correctly formulated and then create a problem only in combination with JQuery menu. http://feedvalidator.org/
Comment #37
off commentedWorks fine! But support of "ajax_load" seems to be unwanted and loading of the first question is to slow..
Comment #38
Armenia commentedhttp://ajax.quiz.drupal.raphaelhuefner.com/install.php?profile=default
hum?
Comment #39
sunnygoa1 commentedhow to make this file run in my quiz??? i extracted it to the modules folder.. it doesnt show the tab for the ajax quiz.. pls help :(
Comment #40
TehJott commentedsunnygoa1: There isn't any ajax tab. You only have to activate the module. Then the questions and feedback are loaded via ajax automatically. (But the module is early dev. Maybe you have to do some work to get it running on your site.)
Comment #41
sunnygoa1 commentedyah i know.. ive tried running the module the way uve mentioned but it just shows the loader.. :( i guess ill hafta work on d ajax module myself lol
Comment #42
djdevin