This patch updates forms and survey modules to work with 4.7. Mostly just converting to formapi. Needs testing and review.

Apply to forms.module v1.15 and survey.module v1.10

Comments

edrex’s picture

StatusFileSize
new12.31 KB

Removed some commented code.

The line which calls formapi at the end of forms_field_form:

    $output.= implode('', forms_invoke_formapi($field, 'edit'));

is commented, because I wasn't sure how to treat it. The formapi hooks aren't actually used by survey module.

DaveNotik’s picture

New to patching. Got this:

patching file forms.module
patching file survey.module
Hunk #2 succeeded at 138 (offset -31 lines).
Hunk #3 succeeded at 202 (offset -31 lines).
Hunk #4 FAILED at 210.
Hunk #5 FAILED at 304.
2 out of 5 hunks FAILED -- saving rejects to file survey.module.rej
edrex’s picture

Check the header of each file and make sure that you have the versions listed above (should be the latest cvs head).

Lemme know otherwise, I'll see if I can coax diff into generating something more compatible. There is probably a doc on drupal.org somewhere that lays out standards for patch formats.

DaveNotik’s picture

I do have those exact versions, according to the header in the respective .module files.

(Trying to run the patch with only one of the two modules in my /patchfiles/ directory obviously results in an error too.)

Can you send me the patched 1.15 and 1.10 modules temporarily? I'd love to be able to get this working for this one project.

Thanks so much! I'll message you via your contact form to alert you of my reply as well.

--Dave

edrex’s picture

StatusFileSize
new17.04 KB

Recent changes to core broke forms module again. This updated patch was generated via `diff -up` as suggested in the section on patches in the "Developing for Drupal" handbook. Please review.

Kieg Khan’s picture

Category: task » support
Priority: Critical » Normal

Hello, I hope I am posting in the right place. I previously was using Drupal 4.6.5 and Forms & Survey, but I am trying Drupal 4.7.0 Beta 3 and the Forms & Survey do not work in that version. I have great interest in 4.7.x as it provides for more security and seems to operate a lot better than 4.6.5 on my IIS powered site.

What I have done is to use the Forms & Survey modules from 4.6.0 modules, created the applicable tables and changed the forms.module and survey.module in the following manner:

My forms.module is headed:

// $Id: forms.module,v 1.14.2.1 2005/10/24 20:47:07 walkah Exp $

Which I am not sure is the same as the ones listed in the attachments on this post

--- modules/forms/forms.module	2005-12-15 20:01:42.768630000 -0800
+++ modules/forms/forms.module	2006-01-11 16:35:13.267355000 -0800

Also, I have not yet worked out the diff process on Windows, so I made the assumption that all code with - in front means remove this code, while all code with + in front means add this code. I also assume that @@ means there is a break in the code and to jump to the next point where code is to be changed. If this is not correct, then I guess I need a lot of help.

When I try to access the module menu I get the following error:

Parse error: syntax error, unexpected '*' in c:\Inetpub\wwwroot\drupal4.7\modules\survey\survey.module on line 25
Call Stack
# Function Location
1 {main}() c:\Inetpub\wwwroot\drupal4.7\index.php:0
2 menu_execute_active_handler() c:\Inetpub\wwwroot\drupal4.7\index.php:15
3 call_user_func_array() c:\Inetpub\wwwroot\drupal4.7\includes\menu.inc:360
4 system_modules() c:\Inetpub\wwwroot\drupal4.7\includes\menu.inc:360
5 drupal_load() c:\Inetpub\wwwroot\drupal4.7\modules\system.module:903

I am sorry I am not a PHP programmer, but I would like to see if I can get these modules going under 4.7.x as they provide really good functionality.

When I use the straight 4.6.5 module, then the module can be activated and the survey appears in the Content->Create Content menu, but nothing happens when I try to create a survey. The forms and survey databases also remain un-altered.

If anyone has gotten this working under 4.7.x, is it possible to just have a file attachment of the working modules rather than the diff file? At least this would ensure that there was no error in my diff processing.

Thanks for any help,

Kieg Khan’s picture

Status: Needs review » Closed (fixed)

Hello, sorry for the previous post. I sat down and had another look at the error and it seems I had not included the /* on a comment line. The survey works now.

One other enhancement I would like to see with this would be to check the current user against users who have previously posted. This way a user could only submit a survey once (a check box in the survey design could be used to enable this checking feature).

I would see this as working with surveys that require a user to be logged in, but when the survey is open to anonymous users, then this check would be disabled.

I do not know how hard this would be to implement, but given that the user details are saved in the survey response and that the survey is IDed in the database, I would think it would be a simple check when the submit button is pressed or when the survey is originally opened. If you did the check immediately the survey was opened, then it might cause problems with the editor not being able to edit the survey if they had filled one in, so when the submit button is clicked would be the best time.

Thanks.

starflyer’s picture

thanks for updating this module. does the excel output work with the patch?

seanr’s picture

Category: support » feature
Status: Closed (fixed) » Needs review

excel output works fine for me, but I'm still testing it. I have not found any other bugs in it yet (but haven't yet tested validation). +1 for this patch. I think this needs to be committed - 4.7 is almost out and we still don't have a 4.7 version of this module. It's time to change that. ;-)

evelien’s picture

Status: Needs review » Active

cvs is showing me survey.module v1.11, which isn't working with 4.7beta6. Any news on when 1.11 will be updated? So I can decide what to do (try 1.10 with this patch or wait for the next edition of survey.module)

starflyer’s picture

hey sean. could you post your updated survey/forms modules? i'm using 4.7 and have the forms_survey_4_7_1.patch installed, but there are 2 critical issues:

- it isn't saving the results when i submit a survey
- excel download isn't working

jmiccolis’s picture

StatusFileSize
new15.86 KB

I just got forms and survey working on the 4.7rc. I used the patch above and made a bunch additional changes myself. Attached is a patch that should apply cleanly to forms.module,v 1.15 and survey.module,v 1.11

cvining’s picture

Just upgraded to Drupal 4.7. This patch worked perfectly for me. Thx so much!

DaveNotik’s picture

tablesort_pager() recently went, so it seems survey.module is once again broken on 4.7.0 -- can't export Excel file, and can't save a survey.

Fatal error: Call to undefined function: tablesort_pager() in /hsphere/local/home/jewishce/jewishcenter.org/sites/jewishcenter.org/modules/survey/survey.module on line 384

Fatal error: Call to undefined function: node_validate_title() in /hsphere/local/home/jewishce/jewishcenter.org/sites/jewishcenter.org/modules/survey/survey.module on line 110
jmiccolis’s picture

Priority: Normal » Critical
Status: Active » Needs work

yea, both node_validate_title() and tablesort_pager() have been removed. Thankfully updating a module for both these changes is pretty simple. http://drupal.org/node/22218#node_validate_title

I'll try to put another patch up this weekend.

Also, I'm raising this to critical as 4.7 is now the stable drupal release.

DaveNotik’s picture

Thanks so much for the tip. :)

Changing line 384 from:

    if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {

to:

    if ($pager = theme('pager', NULL, 50, 0)) {

did the trick for me.

--Dave

urbanfalcon’s picture

StatusFileSize
new2.35 KB

Using jmiccolis's patch on CVS versions of forms and survey (forms.module,v 1.15 and survey.module,v 1.11) worked for me as well, although I did need to clean up that one tablesort_pager issue. Other than that, two thumbs up. Now forms and survey just need install files...

pcwick’s picture

I seem to have just learned how to patch files ha, ha, ha. And to think when I started all this I just wanted to make websites.

I used the the patch in message #12 by jmiccolis on survey.module v1.11 and forms.module v1.15. I split the patch into two files to reduce the number of errors that patch returned, ha.

I also included the install and database files in message #17 by urbanfalcon.

Database seems to have updated cleanly and everything seems to be working well except I cannot download excel files. I get a "page not found" error when I click on the "download to excel" link. Nice feature though not essential. I'm wondering if anyone else is still having difficulty downloading excel files, or if I missed something?

Thanks all for bringing this module up to speed.

seanr’s picture

Can we PLEASE get this committed?
http://drupal.org/files/issues/forms_survey_4.7.patch

It's working just fine here!

Kimeros’s picture

Category: feature » bug
Priority: Critical » Normal

There appears to be a bug in the survey module which stops you from downloading the results in Excel format. This bug only occurs when all of the questions in the survey have the same Weight. The problem has been isolated to function survey_excel() - the code does not return from the following line if the weights are all the same:
while ($response = db_fetch_object($res)) {

This was with Drupal 4.7 and the patched version of the Survey module. MySQL version 4.0.24, PHP version 4.3.10-16

pcwick’s picture

I am unable to download an excel file even though the survey has weights assigned to the form items. Getting "Page Not Found" error.

Zack Rosen’s picture

Status: Needs work » Needs review
StatusFileSize
new15.98 KB

Teste this patch. Everything works fine except for viewing the responses of a survey. The code was calling tablesort_pager() which has been removed. I added a fix for this to the patchfile.

robin monks’s picture

Status: Needs review » Needs work

I tested Zack's copy of the patch on fresh HEAD copies of forms and survey, the patch b0rked:

#patch -p0 < forms_survey_4.7.patch.2
patching file forms/forms.module
patching file survey/survey.module
Hunk #7 FAILED at 331.
1 out of 7 hunks FAILED -- saving rejects to file survey/survey.module.rej
#cat survey/survey.module.rej
***************
*** 294,312 ****

    if ($response_id) {
      $response = db_fetch_object(db_query("SELECT * FROM {survey_responses} WHERE rid=%d", $response_id));
-     $content = form_item(t('submitted by'), format_name(user_load(array('uid' => $response->uid))));
-     $content.= form_item(t('date'), format_date($response->created));

      $res = db_query("SELECT f.title, r.value FROM {survey_fields} r INNER JOIN {form_fields} f ON f.ffid=r.ffid WHERE r.rid=%d ORDER BY f.weight", $response->rid);
      while ($field = db_fetch_object($res)) {
-       $content.= form_item($field->title, $field->value);
      }
    }
    else {
      $header = array(t('Submitted by'), t('Date'), '');
      $res = pager_query("SELECT u.uid, u.name, r.created, r.rid FROM {users} u INNER JOIN {survey_responses} r ON r.uid=u.uid WHERE r.nid=%d ORDER BY created DESC", 50, NULL, NULL, $survey->nid);
      while ($response = db_fetch_object($res)) {
-       $rows[] = array(format_name($response), format_date($response->created),
                        l(t('view'), 'node/'.$survey->nid.'/responses/'.$response->rid));
      }
-     if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {
--- 331,349 ----

    if ($response_id) {
      $response = db_fetch_object(db_query("SELECT * FROM {survey_responses} WHERE rid=%d", $response_id));
+     $content = '<div>' . t('submitted by') . ' ' . theme('username', user_load(array('uid' => $response->uid)));
+     $content.= ' on ' . format_date($response->created).'</div>';

      $res = db_query("SELECT f.title, r.value FROM {survey_fields} r INNER JOIN {form_fields} f ON f.ffid=r.ffid WHERE r.rid=%d ORDER BY f.weight", $response->rid);
      while ($field = db_fetch_object($res)) {
+       $content.= '<div><strong>' . $field->title . ': </strong>' . $field->value . '</div>';
      }
    }
    else {
      $header = array(t('Submitted by'), t('Date'), '');
      $res = pager_query("SELECT u.uid, u.name, r.created, r.rid FROM {users} u INNER JOIN {survey_responses} r ON r.uid=u.uid WHERE r.nid=%d ORDER BY created DESC", 50, NULL, NULL, $survey->nid);
      while ($response = db_fetch_object($res)) {
+       $rows[] = array(l($response->name, 'user/'. $response->uid, array('title' => t('View user profile.'))), format_date($response->created),
                        l(t('view'), 'node/'.$survey->nid.'/responses/'.$response->rid));
      }
+     if ($pager = theme('pager', NULL, 50, 0)) {

Robin

Zack Rosen’s picture

StatusFileSize
new16.84 KB

Think I fixed it. Seems to work fine for me now...

crashpoint’s picture

hi i was going through the code submitted by zacker for the patch of survey_form. I want to thank you all for pooling in and make the necessary changes in the form module. However I am confused about one thing.

function forms_validate($form, $edit) {
Index: survey/survey.module
===================================================================
--- survey/survey.module (revision 246)
+++ survey/survey.module (revision 248)
@@ -28,10 +28,10 @@
}

The function forms_validate. What does that above part mean? As in I know that add the line survey/survey.module. But where is the code that needs to be replaced for the forms_validate function? We have to put the patches of forms and survey in 2 different modules.
I am not all that conversant with patching and know that the - lines are to be removed and + to be added.

thanks a lot for putting in so much effort for patching the modules. We all users really appreciate that.

seanr’s picture

Priority: Normal » Critical

Excel export is broken with this patch. It seems to be getting stuck in a loop but I can;t figure out why. It ends up causing a memory limit error even with memory_limit set to 96MB.

seanr’s picture

BTW, this problem is not related to the weights issue described above - mine are not all different since -5 to 5 is an insufficient range for the number of fields I've got (15), but they're not all the same either.

seanr’s picture

StatusFileSize
new18.24 KB

The attached patch fixes the excel export issue.

pcwick’s picture

Thanks seanr. I'll try it as soon as I get a chance. Does your patch, Attachment: forms_survey_4_7_3.patch (18.24 KB), replace all the previous patches in this thread (except the install.zip file)?

robin monks’s picture

Patch fails:

http://pastebin.ca/67829

Survey patches correctly however.

Robin

puregin’s picture

Category: bug » feature
Status: Needs work » Needs review
StatusFileSize
new9.63 KB

For what it's worth, here is a another patch of survey module only, (generated using diff -u -F^f) based on edrex's original patch plus some of my fixes/cleanup.

I'll attach a patch for forms.module in a separate issue for the forms module.

jasonwhat’s picture

Is there a patched version of this up in CVS yet? If not (I don't see any cvs messages since Feb.) when can we expect it?

walkah’s picture

Status: Needs review » Fixed

committed thanks all!

Anonymous’s picture

Status: Fixed » Closed (fixed)