When we look at the results in the responses pane, the options are not listed in the same order across all 3 questions - take a look particularly at question 3. http://openlearn.open.ac.uk/mod/questionnaire/report.php?instance=1367&sid=1364&action=vall
This makes it much harder to compare the responses. We realise that the ones that no user have chosen aren't displayed at all, that's fine. I wonder if this is a postgres issue? Postgres doesn't automatically return rows from the database in ID order.
I haven't had a look at the code because I'm not entirely sure where to dig into for this little piece of functionality, but if some-one could point me in the right direction, I'm happy to investigate further.
Jenny
Hi Jenny,
1- I am surprised that you are not using the obvious Rate/Scale question type for your questionnaire. Why are you using radio buttons instead?
2- Anyway, when I reproduce your 3 radio button questions on my moodle-questionnaire version 1.9 (latest available) I am not getting the same as you are (see attached screenshot).
I hope all your "possible answers" are arranged in this logical order:
- Not at all
- Not very
- Fairly
- Very
Joseph

2 - OK that's odd because yes they are arranged in that order. I'll have to dig a bit deeper. Can you point me at the right bit of code for where it gets them out of the database and where the display is called?
Sorry, that would take me quite some time which I can't spare right now. How about upgrading to the latest 1.9 version? that should solve the problem.
Joseph
I'll take a look at the latest code too and see if that will help - thanks.
I think you're probably right about the ORDER BY being missing. Now I just need to find the time to hunt out the right part of the code.
Tim, how can a plugin developer track bugs which are linked to the use of one database rather than the other if that developer does not have access to both mySql and postgres (plus a couple of other databases, I expect)?

As Tim mentioned we've found places in the past where things hadn't been tested under Postgres and worked perfectly well under MySQL.
Postgres is open-source and not a difficult install, so you could just set up another database to connect to for occasional testing. But otherwise, like many developers, its about the community helping out with Postgres testing (or if we offer new stuff, with the MySQL testing!).
Well, I am finding Postgres not all that easy to install.
On the Moodle site there is no easy to use "package" for Windows including postgres, only mysql...
I finally managed to install Postgres (8.3.5), Apache 2 which goes with it and phpPgAdmin on my Windows XP (local) machine. Unfortunately I am now stumped by 2 (maybe linked problems).
a) In phpPgAdmin I cannot log in to PostgreSQL; it wants a username and password which I do not know how to provide; I would prefer to log in without a password (since this is only on my local machine); I have looked at the documentation, I have put the necessary "trust" lines in pg_hba.conf but to no avail...
b) When I try to install moodle (1.9), I can see the initial install screen, I fill in the address of the moodledata folder, click on Next and after some time, get only a blank page.
Jenny (and Tim) do you know of the existence of step-by-step instructions for installing moodle with postgres on Windows?
Joseph
b) there must be some kind of fatal error that's not being output. Can you override the debugging level (which is off by default for install) to see what's going on.
I do have postgres running on windows on my laptop, but we usually use linux for our real servers here. I don't remember following any specific instructions for the install though, sorry.
I believe I have found a fix for this issue.
In the get_response_single_results() method of the questionnaire_question class in /mod/questionnaire/questiontypes/questiontypes.class.php I have added an order by id.
-- BEFORE --
// JR added qc.id to preserve original choices ordering
$sql = 'SELECT qc.id, qc.content, COUNT(rt.response_id) AS num '.
'FROM '.$CFG->prefix.'questionnaire_quest_choice qc, '.
$CFG->prefix.'questionnaire_'.$this->response_table.' rt '.
'WHERE qc.question_id='.$this->id.' AND qc.content NOT LIKE \'!other%\' AND '.
'rt.question_id=qc.question_id AND rt.choice_id=qc.id'.$ridstr.' '.
'GROUP BY qc.id,qc.content';
$rows = get_records_sql($sql);
// handle 'other...'
$sql = 'SELECT rt.response, qc.content , COUNT( rt.response_id ) AS num '.
'FROM '.$CFG->prefix.'questionnaire_response_other rt, '.
$CFG->prefix.'questionnaire_quest_choice qc '.
'WHERE rt.question_id='.$this->id.' AND rt.choice_id=qc.id'.$ridstr.' '.
' GROUP BY rt.response,qc.content';
------------
-- AFTER --
// JR added qc.id to preserve original choices ordering
$sql = 'SELECT qc.id, qc.content, COUNT(rt.response_id) AS num '.
'FROM '.$CFG->prefix.'questionnaire_quest_choice qc, '.
$CFG->prefix.'questionnaire_'.$this->response_table.' rt '.
'WHERE qc.question_id='.$this->id.' AND qc.content NOT LIKE \'!other%\' AND '.
'rt.question_id=qc.question_id AND rt.choice_id=qc.id'.$ridstr.' '.
'GROUP BY qc.id,qc.content ORDER BY qc.id';
$rows = get_records_sql($sql);
// handle 'other...'
$sql = 'SELECT rt.response, qc.content , COUNT( rt.response_id ) AS num '.
'FROM '.$CFG->prefix.'questionnaire_response_other rt, '.
$CFG->prefix.'questionnaire_quest_choice qc '.
'WHERE rt.question_id='.$this->id.' AND rt.choice_id=qc.id'.$ridstr.' '.
' GROUP BY rt.response,qc.content,qc.id ORDER BY qc.id';
-----------
The only thing I'm not sure about is if this fix will need to be done in other areas for different question types. I don't know the questionnaire module well at all!
If you want to compare the fix to the old one go to the following URL's
OLD: http://openlearn.open.ac.uk/mod/questionnaire/report.php?instance=1367&sid=1364&action=vall
NEW: http://openlearnacct.open.ac.uk/mod/questionnaire/report.php?instance=1367&sid=1364&action=vall
Also I don't have commit access to the contrib CVS area, do you want this committing back? If so I will pass it onto Jenny.
Would you please re-post full details of this bug and your fix to the moodle bug tracker so that either Mike or myself can check it and commit the necessary changes to contrib as soon as possible?
If possible attach your fix as a PATCH to your bug report.
Thanks in advance,
Joseph
bug tracker page for the Questionnaire module
Bug re-created @ http://tracker.moodle.org/browse/CONTRIB-877
Patch is attached to the bug.
Hopefully that will be everything you need to get the fix in.
If there is anything else you need just shout.