Questionnaire Module - First Release

Questionnaire Module - First Release

by Mike Churchward -
Number of replies: 24
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi -

I've completed my first release of integrating the phpESP survey manager tool into Moodle. I call the module the 'questionnaire' module.

It installs as a Moodle module, but uses the native phpESP application to create and manage surveys. Check the readme file for more information.

Although the phpESP code is generally intact, I had to modify a lot of code to change the way they access data tables - all the SQL calls used hard-coded table names. This version uses configurable names, allowing it to work with the same database.

I have attached the module as a zip to this post (part 1) and the next part in the next post.

(Should I be uploading it into CVS Contrib?)

mike

Average of ratings: -
In reply to Mike Churchward

Re: Questionnaire Module - First Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Here is the text from the readme file:

The questionnaire module allows you to construct questionnaires (surveys) from a variety of question type. It is based on phpESP, and Open Source survey tool (see: http://phpesp.sourceforge.net).

This version has been partially integrates into Moodle -- questionnaires become modules that can be added to courses and all of the data is contained in the Moodle database.

However, creation and management of questionnaires is handled by the phpESP management application. This allows you to use the phpESP edit, test, activate and archive management features as well as the group and designer features. This actually works well, as it separates the questionnaire management functions from the course functions, which seems to be quite a natural separation. Any created questionnaires can be added to courses, allowing you to keep a library of questionnaires.

The group and designer features allow you to set up categories of questionnaires. To create or edit a questionnaire, or review its results, you need to be a member of the group it belongs to.

Consult the phpESP help and documentation for more information.

To Install:

1. Load the questionnaire module directory into your "mod" subdirectory.
2. Visit your admin page to create all of the necessary data tables.


You will need to manually set up some config options for phpESP. In the "questionnaire/phpESP/admin" directory, edit the "phpESP.ini.php" file. Here are the changes you (may) need to make:

1. $ESPCONFIG['base_url'] - if your moodle site is not the root level, insert the appropriate starting directory.
2. Database information - basically, set it up as you did your 'config.php' for Moodle.
3. Moodle Additions - if you use a "prefix" for your Moodle tables, set MDL_PREFIX to that. If not, set it to "".

To access your phpESP management functions, go to:
http://[yoursite]/[yourroot]/mod/questionnaire/phpESP/admin/

Your default login is:
 u: root
 p: esp

You can change this once you are in.

Next up:
1) Currently, you have to enter the "id" of the survey you created when you add a questionnaire to your course. Next steps is to change that to a drop-down list of available surveys.
2) Fully integrate the management functions into Moodle.
3) Fully integrate the reporting functions into Moodle.
4)

In reply to Mike Churchward

Re: Questionnaire Module - First Release

by W Page -

Hi!

PROBLEM 1

I tried to install the module, but when I went to the "Admin" I received the following  error messages.

Error

mts-v1.2-012804 -> Setting up module tables     
--------------------------------------------------------------------------------
(mysql): CREATE TABLE mdl_questionnaire_realm ( name CHAR(16) NOT NULL, title CHAR(64) NOT NULL, changed TIMESTAMP(14) NOT NULL DEFAULT '', PRIMARY KEY(name))  
--------------------------------------------------------------------------------
1067: Invalid default value for 'changed'

Error

--------------------------------------------------------------------------------
(mysql): CREATE TABLE mdl_questionnaire_respondent ( username CHAR(64) NOT NULL, password CHAR(16) NOT NULL, auth CHAR(16) NOT NULL DEFAULT 'BASIC', realm CHAR(16) NOT NULL, fname CHAR(16), lname CHAR(24), email CHAR(64), disabled ENUM('Y', 'N') NOT NULL DEFAULT 'N', changed TIMESTAMP(14) NOT NULL DEFAULT '', expiration TIMESTAMP(14), PRIMARY KEY (username, realm))  
--------------------------------------------------------------------------------
1067: Invalid default value for 'changed'

Error

--------------------------------------------------------------------------------
(mysql): CREATE TABLE mdl_questionnaire_designer ( username CHAR(64) NOT NULL, password CHAR(16) NOT NULL, auth CHAR(16) NOT NULL DEFAULT 'BASIC', realm CHAR(16) NOT NULL, fname CHAR(16), lname CHAR(24), email CHAR(64), pdesign ENUM('Y', 'N') NOT NULL DEFAULT 'Y', pstatus ENUM('Y', 'N') NOT NULL DEFAULT 'N', pdata ENUM('Y', 'N') NOT NULL DEFAULT 'N', pall ENUM('Y', 'N') NOT NULL DEFAULT 'N', pgroup ENUM('Y', 'N') NOT NULL DEFAULT 'N', puser ENUM('Y', 'N') NOT NULL DEFAULT 'N', disabled ENUM('Y', 'N') NOT NULL DEFAULT 'N', changed TIMESTAMP(14) NOT NULL DEFAULT '', expiration TIMESTAMP(14), PRIMARY KEY(username, realm))  
--------------------------------------------------------------------------------
1067: Invalid default value for 'changed'

Error

--------------------------------------------------------------------------------
(mysql): INSERT INTO mdl_questionnaire_realm ( name, title ) VALUES ( 'superuser', 'ESP System Administrators' ), ( 'auto', 'Self added users' )  
--------------------------------------------------------------------------------
1146: Table 'db95030403.mdl_questionnaire_realm' doesn't exist

Error

--------------------------------------------------------------------------------
(mysql): INSERT INTO mdl_questionnaire_designer (username, password, fname, lname, realm, pdesign, pstatus, pdata, pall, pgroup, puser, disabled) VALUES ('root', PASSWORD('esp'), 'ESP', 'Superuser', 'superuser', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N')  
--------------------------------------------------------------------------------
1146: Table 'db95030403.mdl_questionnaire_designer' doesn't exist

Error

--------------------------------------------------------------------------------
(mysql): CREATE TABLE mdl_questionnaire_survey ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, name CHAR(64) NOT NULL, owner CHAR(16) NOT NULL, realm CHAR(64) NOT NULL, public ENUM('Y', 'N') NOT NULL DEFAULT 'Y', status INT UNSIGNED NOT NULL DEFAULT '0', title CHAR(255) NOT NULL, email CHAR(64), subtitle TEXT, info TEXT, theme CHAR(64), thanks_page CHAR(255), thank_head CHAR(255), thank_body TEXT, changed TIMESTAMP(14) NOT NULL DEFAULT '', PRIMARY KEY (id), UNIQUE(name))  
--------------------------------------------------------------------------------
1067: Invalid default value for 'changed'

Error

--------------------------------------------------------------------------------
(mysql): CREATE TABLE mdl_questionnaire_response ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, survey_id INT UNSIGNED NOT NULL, submitted TIMESTAMP(14) NOT NULL DEFAULT '', complete ENUM('Y', 'N') NOT NULL DEFAULT 'N', username CHAR(64), PRIMARY KEY (id))  
--------------------------------------------------------------------------------
1067: Invalid default value for 'submitted'

Error

questionnaire tables could NOT be set up successfully!

Then under the continue link was this message

--------------------------------------------------------------------------------
(mysql): SELECT * FROM mdl_course WHERE category = '0' LIMIT 1  
--------------------------------------------------------------------------------

PROBLEM 2

My site is like this,

http://MyWebSite.com/moodle/

Just wanted to check if I completed the "questionnaire/phpESP/admin/phpESP.ini.php" file correctly,

/**
 * Here are all the configuration options.
 */

// Base URL for phpESP
// The string $server['HTTP_HOST'] will be replaced by the server name
$ESPCONFIG['MyWebSite.com/moodle'] = 'http://' . $server['HTTP_HOST'] . '/mod/questionnaire/phpESP/';

// URL of the images directory (for <img src='...'> tags)
$ESPCONFIG['MyWebSite.com/moodle/mod/questionnaire/phpESP/'] = $ESPCONFIG['base_url'] . 'images/';

// URL of the automatic survey publisher
$ESPCONFIG['MyWebSite.com/moodle/mod/questionnaire/phpESP/'] = $ESPCONFIG['base_url'] . 'public/survey.php';

// URL of the CSS directory (for themes)
$ESPCONFIG['css_url'] = $ESPCONFIG['base_url'] . 'public/css/';

// Database connection information
$ESPCONFIG['db_host'] = 'db12.perfora.net';
$ESPCONFIG['db_user'] = 'dbo12345678';
$ESPCONFIG['db_pass'] = 'ABCdEfgh';
$ESPCONFIG['db_name'] = 'db12345678';

How can I correct the errors?

WP1

In reply to W Page

Re: Questionnaire Module - First Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

It looks like the SQL for creating the phpESP tables has a flaw that doesn't work on some MySQL installations. I can change that file and you can try again. I think you will have to delete the "questionnaire" module if it is showing up in your "Modules" list on you admin page, and/or you may have to manually remove the "questionnaire_" tables from your database.

I'll post the new file here.

For your config file, you should leave everything on the "left" side of the "=" sign alone; it shouldn't be changed.

So you should only have to change the base url. In your case, change:
   /mod/questionnaire/phpESP/
to:
   /moodle/mod/questionnaire/phpESP/

The only thing else you need to change is the database entries with your host, user, password and database name.

In reply to Mike Churchward

Re: Questionnaire Module - First Release

by W Page -

Hi Mike!

I deleted the "questionnaire" directory and uploaded a fresh "questionnaire" directory.

I also made the changes to "phpESP.ini.php" that you indicated along with the proper database values.

I changed,
// Base URL for phpESP
// The string $server['HTTP_HOST'] will be replaced by the server name
$ESPCONFIG['base_url'] = 'http://' . $server['HTTP_HOST'] . '/mod/questionnaire/phpESP/';

to,
// Base URL for phpESP
// The string $server['HTTP_HOST'] will be replaced by the server name
$ESPCONFIG['base_url'] = 'http://' . $server['HTTP_HOST'] . '/moodle/mod/questionnaire/phpESP/';

The database installed easily this time, no errors.

PROBLEM 1
I could not get to the admin of phpEsp.  I received a "500" error.  I typed something like the following in the address bar,
http://MyWebSite.com/moodle/mod/questionnaire/phpESP/admin/

PROBLEM 2
There are no images in the "/moodle/mod/questionnaire/phpESP/images/surveyimages" directory.

PROBLEM 3
There is an incomplete "questionnaire" directory in "questionnaire-2.zip".

Thanks for your help,  Almost there.

WP1

In reply to W Page

Re: Questionnaire Module - First Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Glad you got the database to work.

Problem 1 - 500 Error:
Did you get the login prompt? Could you login?
A 500 error, is an unexpected condition. I think this happens a lot when a script doesn't return what its supposed to. I'm really not sure what would be causing that...
What server are you installing this on? Does it make any difference if you go directly to the index page - i.e. http://mywebsite.com/moodle/mod/questionnaire/phpESP/index.php ?

The images are in the questionnaire-2.zip. I split it into 2 to get around the 500K limit for uploading files. When you look at the zip file you should see a listing like the one attached.

mike

Attachment winzip.jpg
In reply to Mike Churchward

Re: Questionnaire Module - First Release

by W Page -

Hi!

Thanks for responding.

PROBLEM 1 - Persists
I could never get to the login prompt 
If I attempted to reach,
http://MyWebSite.com/moodle/mod/questionnaire/phpESP/admin/
>> 500 Error

If I went to,
http://MyWebSite.com/moodle/mod/questionnaire/

>>A required parameter is missing (inside of moodle).

The server is provided by 1abd1.com
Apache Server: 1.3
php : 4.2.3

Cannot figure this out.  It is really frustrating.  Everyone else who has posted appear to have had relatively easy installations. sad sad

PROBLEM 2 - Resolved
In "questionnaire-2.zip"  the images are located in this path,
/questionnaire/phpESP/images
not
/surveyimages
Suggest you make up a new "questionnaire-2.zip" with the following path to images alone,
/questionnaire/phpESP/images
The fact that an incomplete questionnaire folder and the surveyimages folder (which is empty) are both in the "questionnaire-2.zip" may be causing some confusion regarding the presence of images in the file.

PROBLEM 3 - Persists
Please see problem 3 above.

WP1

In reply to Mike Churchward

Re: Questionnaire Module - First Release

by W Page -

Hi!

I installed the "questionnaire" mod on another MOODLE install I have on another server.  It was the 2nd Release.  It installed without a problem.

However I cannot login to the admin page.  I checked the database and "root" is present as the UserID.  I cannot verify "esp" as the password because it is encrypted.  The encription is not that long so I could not test it by swapping the encrypted password with the encrypted password of a password I knew.  The other passwords I have are longer encryption strings and will not fit in the password textbox in the phpESP database.

Any suggestions??

WP1

In reply to W Page

Re: Questionnaire Module - First Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

If you look at the SQL file in the install set, it installs the 'root' account with the 'esp' password (encrypted using the MySQL password function). So, it should definitely be esp. This is in the 'questionnaire_designer' table.

I've had problems with Windows installations of phpESP, but so far not a Unix one.

You can turn off using designer passwords by changing the setting:

// Use authentication for designer interface (BOOLEAN)
$ESPCONFIG['auth_design'] = true;

to 'false' in the 'phpESP.ini.php' file. That should let you in to the admin screen.

mike

In reply to Mike Churchward

Re: Questionnaire Module - First Release

by Ger Tielemans -

Nice install, thanks:

Install seems to work under Debian Linux, only images for the buttons of espPHP are not found.

Creating a test is ok, activate also, but Moodle does not agree that it is accessible

In reply to Ger Tielemans

Re: Questionnaire Module - First Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

The images are in the second zip file I posted (in the post after the first one).

I'm not sure what you mean by "Moodle does not agree that it is accessible"? What's happening?

mike

In reply to Mike Churchward

Re: Questionnaire Module - First Release

by Ger Tielemans -

second zip contains folder surveyimages, but that one is empty

I create a survey, then I make it active, then I go to a moodle section and choose questionaire and fill in the id number of the survey. If I try to start the survey it gives that message: That questionnaire is not available yet. Try again later.

If I visit the database I see the surveys I created with status 3 (and one Idid close: 4)

In reply to Ger Tielemans

Re: Questionnaire Module - First Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Ger -

Try downloading the second file again. I just tested it, and the files were there...

Status 3, means you 'ended' the survey. Its not available for useage.

Staus 9, is active, and the only one that will allow the survey to work. On the management screen, you change the status of the survey with "Change Status" page. Unfortunately, it looks like phpESP won't let you reactivate a survey that has been 'ended'. You can copy it though, and activate the copy (but you'll need to update the survey id in your questionnaire resource).

I'll update the mod to have nicer messages, decribing why you can't access it. Additionally, I will change the add portion so you can pick the survey you want, rather than entering the survey id.

For the record, the status values are (from phpESP):
0 - editing,
3 - ended,
4 - archived (deleted)
8 - testing
9 - active.

mike

In reply to Mike Churchward

Re: Questionnaire Module - First Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

I apologize, I have to update this. There are two active status values: 1 and 9.

9 means it was first tested and then became active; 1 means it went straight to active. So, the table should read:

0 - editing,
1 - active,
3 - ended,
4 - archived (deleted)
8 - testing
9 - active.

I will release a fix shortly.

mike

In reply to Mike Churchward

Re: Questionnaire Module - First Release

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Keep up the good work, Mike! 

I actually considered phpESP as a base for the Quiz module and ended up deciding to start from scratch.  But this was a long time ago and everything's evolved a lot since then!
In reply to Martin Dougiamas

Re: Questionnaire Module - First Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Thanks Martin -

I wanted to use the Quiz module for this purpose, but it started to be too much of a compromise. I really needed to include short answer responses (with no right answer) into the page, but I couldn't do that with the quiz. Besides, for a questionnaire, I'm not interested in grading - just responses. Similar to your survey tool.

Ideally, it would be nice to merge the two. Adding the questionnaire module means that we have a lot of similar tables holding question information. Ah, well... over time...

mike

In reply to Martin Dougiamas

Re: Questionnaire Module - First Release

by Art Lader -
This looks great. Thank you so much for all of your work, Mike.

Martin, the survey module will not disappear after this module is implemented, will it?

Thanks,
Art Lader
In reply to Mike Churchward

Re: Questionnaire Module - Second Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

This is release two of the questionnaire.

It contains a fix that allows both "active" states of surveys to be used.
It also now lists the active surveys by name, instead of forcing you to enter survey id as a number, when you add a questionnaire to a course.

QUESTION-
Would we want to be able to add non-active surveys? I'm thinking now, we would. That way we could have them ready in the course, and activate them when we want.
Thoughts?

mike

In reply to Mike Churchward

Re: Questionnaire Module - Second Release

by Ger Tielemans -

OK, works fine now under windows2000/easyphp1.7

Also working under debian linux,only the debriefing screen is not found (some settings I guess)



Nice, my favorit cross table is in it


Can students also use this option? (creating a survey and then analyse it?)

In reply to Ger Tielemans

Re: Questionnaire Module - Second Release

by Floyd Collins -
Installed and works fine on my Mac OSX server. Thank You. 
In reply to Ger Tielemans

Re: Questionnaire Module - Second Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

You can let anyone access the designer and anlysis functions in two ways:

1. You can give them their access to an account, or
2. Turn off designer accounts. You do this by setting the
        $ESPCONFIG['auth_design'] = true; to false in the 'phpESP.ini.php' file.

mike

In reply to Mike Churchward

Re: Questionnaire Module - Second Release

by W Page -

Hi!

Thanks for responding.

I followed your suggestion on both sites,
$ESPCONFIG['auth_design'] = true; to false in the 'phpESP.ini.php' file

IT WORKED!  I was able to reach the  Admin page.  Do you have any suggestions as to why I could not reach the admin pages on these sites before.

  • 500 Error Page?
  • Could not log in although login window came up?

I need to find some way to keep these pages secure but still accessible.  Any suggestion on how to achive this would be appreciated.

WP1

In reply to W Page

Re: Questionnaire Module - Second Release

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

phpESP uses HTTP Authentication. From what I can see, that 'generally' works, but there are exceptions.

I'm rewriting the phpESP auth library to use Moodle logins. That should fix your problem as well.

How it will work is that I will always allow the Moodle 'admin' account into the phpESP admin page. From there, you can add any other Moodle users you want to the phpESP designer or admin functions.

mike

In reply to Mike Churchward

Re: Questionnaire Module - Second Release

by W Page -

Hi Mike!

Thanks again!

WP1