I have been working on this module for the past few days and have got to a point where I have made a patch of the 1.65 CVS version... This is my first real attempt at patching, so forgive me if I've got it all wrong...

Changes

  • Quiz works on the new schema which WebChick set out here
  • Added a "quiz admin" section where results can be viewed in a table and individual answers can be seen
  • Generally tweaked it all up

There are probably plenty of bugs left in - but this is a preliminary submission. One thing that remains is the scoring - I'm not happy with the way it works, but it does work. It doesn't store the result in the results table, it works it our for each one everytime

I'd also like to implement some taxonomy filters on the admin/quizzes page.

I'd appreciate people's feedback on this.

Comments

robertdouglass’s picture

Great work Nic! With this and the gradebook module coming into action, Drupal is going to start making waves in the education scene!

deekayen’s picture

With as stale as this module has gotten, are there any objections to just committing this patch and file new bugs from that point, or does anyone want to give this patch a review?

webchick’s picture

Status: Needs review » Needs work

Yeah, I think go for it. I browsed through the patch and apart from some minor code style things, nothing stands out to me.

However, the .install file is missing and since the schema was changed, the whole thing will come crashing down without that, methinks.

Thanks very much, Nicholas! If you could just attach your quiz.install file, I think this is probably good to go.

nicholasthompson’s picture

Oopsy! Of course! I'll do that first thing tomorrow morning (UK Time). Just out of interest, what were the coding style issues? I read through the docs and tried to standardise it where I thought was necessary. I'd appreciate knowing where I went "wrong".

Once this is submitted, I have some more work scheduled to do to this over the coming week. This includes the ability for a user to review all their results and a few other extra's.

deekayen’s picture

I agree it's not anything big, but I can always be picky without even having run it :)

I ordered them in my opinion of significance:

  • _quiz_get_results() is missing brackets around the table names for table prefix replacement
  • foreach is convenient, but doing a while(list($key, $value) = each($var)) is way faster and less memory intensive because foreach makes a copy of the array before it cycles where each just moves the pointer
  • empty() is a little faster than $var == '' (if the check is equivalent)
  • if statements should have a space between if and (
  • there should be a line break after brackets/before else's (http://drupal.org/node/318)
  • Double quotes have extra meaning and a smidge more overhead so explode("-", substr( could be explode('-', substr(
nicholasthompson’s picture

StatusFileSize
new9.12 KB

I've applied the suggestions you made - thanks for taking the time to do that. The foreach/while thing is unbelievable. I seriously think that might be why the Cateogies module is so damn slow... I attach a file containing a new patch (based on the 10.05.06 CVS version

  • I was unaware thats what the brackets were for in queries - you learn something new everyday!
  • As I said - the foreach/while competition blew me away... Never using foreach again!! Is it quicker to make a function return its results to a variable and then use the while method on the variable, or just put the function into the foreach? The while method doesn't seem to work with functions directly...
  • Again - new info. Will use empty() more often
  • Changed - must get into that habbit
  • Thanks - I thought I'd done that one, but there were two lines with else's on them in the multichoice module
  • Interesting about the double quotes... I knew they had different "meaning" but didn't know there was a performance hit!

Thanks again - I attach the new file.

webchick’s picture

Excellent, thanks! I've had a chance to test this, and have some additional feedback... most of this is minor, except the last point... any chance you could take another look?

  • Under node/add/multichoice, there's a "Delete" column with nothing in it. The checkboxes are there on node/##/edit though. I'd just remove the delete column on add.
  • I'm seeing the question printed twice on node/##
  • Open date and close date should default to today's date, rather than Jan 1 1900.
  • When adding a quiz, I get the following printed to the screen:
    query: INSERT INTO quiz (nid, number_of_questions, shuffle, backwards_navigation, feedback_time, open, close, takes) VALUES(17, 2, 1, 0, 1, '2006-8-9', '2006-8-12', 1)
    

    (there's a db_queryd stuck in the patch somewhere)

  • Possibly due to the above error, when I click "take quiz" I just get Your score: 0, no question actually there for me to click.
nicholasthompson’s picture

Thanks Webchick - most of those are on my to do list for the next week.

  • Not sure why the double question appears - most likely a body/teaser issue.
  • If you're describing what I think you're describing on the multichoice page, the delete column is for when options exist so you can remove options. You make a good point though - there is no need to have a delete column if the operation is create!
  • Default dates is on the to-do-list
  • Interesting - thought I'd removed all debugging! Will have to look again
  • Feedback is on the to-do-list

The reason I submitted the patch "early" was so the public version could at least be semi-working. There is still, as you've pointed out, PLENTY to do. I have many plans for this module :-)

webchick’s picture

No, that's cool. I'm all about incremental patches. :) However, I can't get your version of quiz module to actually work (same problem as the current one; can't take quizzes). Can someone else test this patch and let me know if I'm just on crack, or if it's a PHP 5 thing, or..?

nicholasthompson’s picture

My dev server is PHP4.0 (I think), so unless they've decided to depreciate something usefull - it shouldn't be that.

Its more than possible I've made a booboo making the patch - not particularly experienced at this side of Drupalling yet ;-)

What exactly are the problems you're experiencing?

Currently you can take tests but when it finishes you just get your overall score.

When I get a minute I'll try to download a clean Quiz install and apply the patch myself (while keeping a backup of my current version!)

webchick’s picture

What exactly are the problems you're experiencing?

I created two multichoice questions, then a quiz with 2 questions, then clicked the "take quiz" tab, I just get "Your score: 0", no question actually there for me to click.

nicholasthompson’s picture

Now THATS interesting! Were the questions set to Always? Was the quiz within the date range you set for it?

webchick’s picture

Status: Needs work » Reviewed & tested by the community

Haha, d'oh. Goes to show how long it's been since I last looked at this. ;) Yes, I forgot to add questions to the quiz. That'll do it. ;)

Marking RTBC. I've added you under the CVS access tab for the Quiz project, so please feel free to commit this. Great work!

webchick’s picture

Hey, Nicholas!

Just checking up, as I noticed this wasn't committed yet. Are the CVS permissions working ok? If you don't have time or whatever and would prefer myself or one of the other maintainers to commit this for you, then let me know and we can do that. :) I was just wanting to give you "credit" for the commit (it would show up under your user account as a contribution), since you did all this work. :)

nicholasthompson’s picture

Sorry about the delay - I'll try to get it done today. I've had a really busy few days recently.

webchick’s picture

Hey no problem at all. It's been broken for a few months now, a few more days won't hurt. ;)

seanbfuller’s picture

StatusFileSize
new37.95 KB

Here's a quick updated version of this patch that fixes a few issues:

  • Swapped out two of the db_queryd calls with db_query in quiz.module
  • Fixes a bug in multichoice.module where "quiz_quesions" should have been "quiz_question" (wrong table and a typo)
  • Moved the .install file into the patch (just because phpelclipse made it easy for me to package it that way)

Hopefully that will help get these changes pushed to cvs. If you have another version that is further along, please pardon the post.

nicholasthompson’s picture

Thats fantastic - I'll be trying this VERY soon indeed! I (well actually, my colleague who is going to be picking this up from me) will be looking to submit this to CVS VERY soon. We need this finished and tested for our own product before october.
Unfortunately, until now I've been swallowed up with a project which kept getting bigger (moving a site (http://www.sportbusiness.com) into Drupal).

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Ok, seeing as:

1. It's been way long enough that this has been sitting in the queue. :)
2. Sean is starting to create additional patches and needs something stable to work from
3. Nicholas has informed me that he's no longer working on this

I committed this patch to the module. Thanks a lot for your help, guys!

Anonymous’s picture

Status: Fixed » Closed (fixed)

  • Commit 15dfa66 on 4.7.x-1.x, 5.x-1.x, 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x by webchick:
    #77792 by nicholasThompson, follow-up by Sean B Fuller: An actual...

  • Commit 15dfa66 on 4.7.x-1.x, 5.x-1.x, 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages by webchick:
    #77792 by nicholasThompson, follow-up by Sean B Fuller: An actual...

  • Commit 15dfa66 on 4.7.x-1.x, 5.x-1.x, 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, quiz-pages, 2269219 by webchick:
    #77792 by nicholasThompson, follow-up by Sean B Fuller: An actual...

  • Commit 15dfa66 on 4.7.x-1.x, 5.x-1.x, 5.x-2.x, 6.x-2.x, 6.x-3.x, 6.x-4.x, 6.x-5.x, 6.x-6.x, 7.x-4.x, master, 7.x-5.x, 2269219 by webchick:
    #77792 by nicholasThompson, follow-up by Sean B Fuller: An actual...