## Activities: Questionnaire

mod_questionnaire
Maintained by Mike Churchward
Custom Survey Creation
10075 sites
117 fans

Create your own surveys using this tool.

SUPPORT DISCUSSION: http://moodle.org/mod/forum/view.php?id=2642

NOTE: If you are upgrading to Moodle 2.3 or greater, make sure you have upgraded the questionnaire module to the latest version of Moodle 2.2, in your Moodle 2.2 codebase before upgrading to Moodle 2.3 or greater.

DEVELOPERS NOTE - Questionnaire is tracked in Github at https://github.com/remotelearner/moodle-mod_questionnaire. Contact Mike Churchward if you want "push" access.

(originally based on phpESP)

/plugins/mod

### Contributors

Joseph Rézeau: Former co-maintainer

### Awards

• Tue, 17 Jul 2018, 8:42 PM
Hi Meir. Yes, that is part of the standard function - https://docs.moodle.org/35/en/Questionnaire_module#Export_text_file.
It is a tab when you are looking at the results.
• Wed, 1 Aug 2018, 11:47 PM
Hi Mike,

There's a bug with this plugin in that it doesn't work with MySQL 8.0.12... Given that MySQL 8.0.x is now GA, any chance you can get this fixed? I'm using this on a live server now, the semester has started and we've only just picked up on this issue.

One problem I found is that "rank" is now a reserved word, but got around that using backticks, however couldn't get the rest of it to work.

Here's the debugging info...

Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank
FROM wsu_moodle_cybersec_questionnaire_response qr
' at line 3
SELECT CONCAT_WS('_', qr.id, 'checkboxes', qrm.id) AS id,
qr.submitted, qr.complete, qr.grade, qr.userid, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.firstname, u.lastname, u.username, u.department, u.institution, u.id as usrid, qr.id AS rid, qrm.question_id,
qrm.choice_id, qro.response AS response, 0 AS rank
FROM wsu_moodle_cybersec_questionnaire_response qr
JOIN wsu_moodle_cybersec_questionnaire_resp_multiple qrm ON qrm.response_id = qr.id
AND qr.survey_id = ? AND qr.complete = ?
LEFT JOIN wsu_moodle_cybersec_questionnaire_response_other qro ON qro.response_id = qr.id AND qro.choice_id = qrm.choice_id
LEFT JOIN wsu_moodle_cybersec_user u ON u.id = qr.userid
WHERE qr.id = ? UNION ALL
SELECT CONCAT_WS('_', qr.id, 'textbox', qrt.id) AS id,
qr.submitted, qr.complete, qr.grade, qr.userid, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.firstname, u.lastname, u.username, u.department, u.institution, u.id as usrid, qr.id AS rid, qrt.question_id,
0 AS choice_id, qrt.response AS response, 0 AS rank
FROM wsu_moodle_cybersec_questionnaire_response qr
JOIN wsu_moodle_cybersec_questionnaire_response_text qrt
ON qrt.response_id = qr.id
AND qr.survey_id = ? AND qr.complete = ?
LEFT JOIN wsu_moodle_cybersec_user u ON u.id = qr.userid
WHERE qr.id = ? ORDER BY usrid, id
[array (
0 => '2',
1 => 'y',
2 => 3,
3 => '2',
4 => 'y',
5 => 3,
)]
Stack trace:
line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 1184 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 2597 of /mod/questionnaire/questionnaire.class.php: call to mysqli_native_moodle_database->get_recordset_sql()
line 2782 of /mod/questionnaire/questionnaire.class.php: call to questionnaire->get_survey_all_responses()
line 1902 of /mod/questionnaire/questionnaire.class.php: call to questionnaire->generate_csv()
line 1599 of /mod/questionnaire/questionnaire.class.php: call to questionnaire->response_send_email()
line 277 of /mod/questionnaire/questionnaire.class.php: call to questionnaire->submission_notify()
line 75 of /mod/questionnaire/complete.php: call to questionnaire->view()

This server is

Moodle 3.5.1+ (Build: 20180720)
MySQL 8.0.12
PHP 7.2.8.1.16.04.1.1

Much appreciated!

Cheers,
Ray
• Wed, 1 Aug 2018, 11:54 PM
Mike - Never mind the "the rest of it" comment, it's only the backticks around the reserved word rank that i can tell is the issue. Adding those ticks there processes the command.

Cheers,
Ray
• Thu, 2 Aug 2018, 12:01 AM
Hi Ray. Any chance you could post that as an issue either in the Moodle Tracker, or as a Github issue?
• Mon, 13 Aug 2018, 6:24 PM
Did we get over this, my error

Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank
FROM mdl_questionnaire_response qr
JOIN mdl_que' at line 3

SELECT CONCAT_WS('_', qr.id, 'checkboxes', qrm.id) AS id,
qr.submitted, qr.complete, qr.grade, qr.userid, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.firstname, u.lastname, u.username, u.department, u.institution, u.id as usrid, qr.id AS rid, qrm.question_id,
qrm.choice_id, qro.response AS response, 0 AS rank
FROM mdl_questionnaire_response qr
JOIN mdl_questionnaire_resp_multiple qrm ON qrm.response_id = qr.id

AND qr.survey_id = ? AND qr.complete = ?
LEFT JOIN mdl_questionnaire_response_other qro ON qro.response_id = qr.id AND qro.choice_id = qrm.choice_id
LEFT JOIN mdl_user u ON u.id = qr.userid

ORDER BY usrid, id
[array (
0 => '18034',
1 => 'y',
)]

Cheers
• Tue, 14 Aug 2018, 3:46 AM
I believe this is the reported issue - https://tracker.moodle.org/browse/CONTRIB-7420
• Wed, 29 Aug 2018, 9:05 PM
Regarding the "rank" reserved word issue:
The latest versions in the MOODLE_35_STABLE and MOODLE_34_STABLE branches have fix for this. You can get them from Github.

https://github.com/PoetOS/moodle-mod_questionnaire/tree/MOODLE_35_STABLE
https://github.com/PoetOS/moodle-mod_questionnaire/tree/MOODLE_34_STABLE
• Mon, 3 Sep 2018, 10:58 PM
Hello,
I made a questionnaire (Two sorts of questions : text and single response) which is deployed on a lot of courses (approximately 100). I must download every results on csv files. Is it possible to use an SQL request to recover all results ? If yes, have you a model ?
Thanks,
Alain
• Tue, 18 Sep 2018, 8:50 PM
Hi,

Thank you for this very useful plugin !

I have noticed the possibility to save a draft and resume answering to the questionnaire, though I wonder if it would be possible to add a functionnality that would allow users who have already saved a draft to make a whole new submission (while keeping their previous answers as a separate draft). As of now, the only choice that is left when one has already saved a draft is to "resume participation" (and it is impossible to start a new one).

However, the questionnaire model I have created will be filled by student advisors who will gather information from various students willing to apply for a program in our school. It may well happen that some students won't be able to provide full information to complete the questionnaire in one shot. Thus, I would like advisors to be able to start filling the information for student A (submission 1), save it as a draft, then fill in the full form for student B (submission 2) before resuming and completing the submission for student A (submission 1). I know this might sound quite challenging but nothing ventured, nothing gained !

Thanks for helping anyway !
Best,

Yannick
• Wed, 19 Sep 2018, 3:47 PM
Hello again,

I also wonder if it would be possible to add an "upload file" question type / field within questionnaires ? As a matter of fact, I would like users to be able to send a few PDF attachments while answering the questionnaire.

Thanks for reading and helping !
Best,

Yannick
• Mon, 24 Sep 2018, 11:01 AM
Hi Guys:

Moodle 3.4.2 Version - noted an issue on submitting forms in a LAMP setup.
The UNION ALL in the query Fails on MYSQL.

The error in DEBUG is: Illegal mix of collations for operation UNION
Line 2597 in /mod/questionnaire/questionnaire.class.php

The Query Built results in: "qrb.choise_id AS response" (This is an Integer field)
and in the union calls in different field: "qrt.response AS response" (This is a text field)

All tables are in the same collation, however comparing an integer to a text field results in this issue.

The solution we ended up using was a FIX my MYSQL databases only:
Adding this line above the $DB-.get_recordset_sql function: (line 2600)$allresponsessql = str_ireplace('qrb.choice_id AS response',
'qrb.choice_id COLLATE utf8_unicode_ci AS response', \$allresponsessql);

This resolved the issue for us, but perhaps the SQL needs to be built differently so that integer fields are not unioned against text fields.

Cheers
• Mon, 15 Oct 2018, 6:02 PM
Hi,

I have created a questionnaire model in the hope that its contents would automatically synchronize within the questionnaires using it as their source of contents.

However, I wonder why the "content options" field only appears once in the settings (when adding a new questionnaire) and then disappears : would it be possible to be able to keep changing the content options of a questionnaire even after it was first added in the course ?

Thanks for helping,
Best,

Yannick Vrolant
• Mon, 15 Oct 2018, 6:02 PM
Hi,

I have created a questionnaire model in the hope that its contents would automatically synchronize within the questionnaires using it as their source of contents.

However, I wonder why the "content options" field only appears once in the settings (when adding a new questionnaire) and then disappears : would it be possible to be able to keep changing the content options of a questionnaire even after it was first added in the course ?

Thanks for helping,
Best,

Yannick Vrolant
• Mon, 15 Oct 2018, 10:45 PM
Hi Yannick.
Content options are only present to initially populate the new questionnaire with existing content (or not). It wouldn't make sense to have it available after creation. What would the use case be for that? Please, discuss this in the questionnaire forum so others can be involved.
• Tue, 16 Oct 2018, 8:34 PM
Hi Mike,

Thanks for answering, here is a more detailed explanation of how we use the questionnaire activity (I will also post a message in the forum as suggested):

We work with dozens of student recruiters (agents) who are in charge of filling up the same model form, which means each separate agent should have access to one occurrence of this model form while not seeing the other agents' forms. It is always the same person who answers the questionnaire, (by the way, this is the reason why I had been asking earlier on whether it would be possible to save incomplete questionnaires before starting anew with another answer).
The thing is that when we want to edit the model, we then have to delete all the agents' forms before replacing them with the new updated version of the form.
It would be a real time-saver for us if we could synchronize all of these questionnaires at once whenever we modify the model.
I can understand this is not really the primary use that was initially intended for this plugin but do you think this is something possible ?

Thanks for helping,
Best,

Yannick