For my site, I used the Webforms module to make Course Evaluation forms.
To be able to properly implement a form as a Course Evaluation, it was necessary to have authenticated users fill out a form and not have their names associated with their answers.
However, I also needed to track which users had filled out the form.

After poking through the feature requests, and seeing nothing, I decided to patch the module to give it the appropriate functionality.

There is now a checkbox under the Advanced Settings field that allows you to anonymize a form.

Attached are the three patches to webform.module, webform.inc, and webfrom_report.inc.

However, I was not able to figure out how to document the modification I made to the database.

In order for any of this code to work, you must first go into your database and run this command:
CREATE TABLE webform_anonymizer (nid int,uid int,submitted int);

This is my first patch, so any constructive criticism is appreciated.
Also, if anyone thinks of an easier way to do this, let me know.

Comments

SabbeRubbish’s picture

Hi,

I am really interested in this feature, could it be merged into the core soon?
I don't know too much about patching modules cleanly - let alone write an entire module - but I too need to be able to know who filled in the webform/survey without knowing who answered what.

Please contact me about this as soon as possible.

Thank you.

quicksketch’s picture

Status: Needs review » Needs work

So I know this patch is ancient. There have been several requests in the past for this same feature. I mostly ignored this patch because I assumed it would be a huge undertaking. But after review the patch is quite sane and not even that difficult. Generally a very well written patch. Apologies tim.plunkett for ignoring this for so long.

Only a couple of things needed and I'd be happy to add this to Webform.

1. You can't use the term "anonymizer" for hiding IP Addresses, since Drupal has had trouble with that in the past (so webchick informs me). These guys have the trademark. If you could replace the term with simply "anonymous" that would be great.

2. It seems like this line effectively would kill Cookie tracking:

 -  if ($num_submissions_database >= $node->submit_limit || $num_submissions_cookie >= $node->submit_limit) {
+  if ($num_submissions_database >= $node->submit_limit) {

What's the reason for changing it?

3. Webform has changed a lot since the 1.9 version (which is no longer supported at all). If this can be updated to the latest 2.x version I'll put it in.

felipe’s picture

Hi guys,

any news on this feature?

I'd love to use it to take anonymously submissions. In our faculty many students won't answer the form if we can't asure it is anonymous. Exactly the same situation described here.

I'm using Drupal 6.

Thank you.

hedroom’s picture

StatusFileSize
new1.3 KB
new3.37 KB

I looked at this from a different angle...

I added a checkbox "Make this an anonymous form" in the "Webform advanced settings" section.

Then I changes the code in webform.module and webform_submissions.inc to send and record "Anonymous" and "0.0.0.0" as the user and IP respectively.

Also, I added a column to the webforms table called "anon" to hold the checkbox setting.

ALTER TABLE `webform` ADD `anon` TINYINT NOT NULL DEFAULT '0' AFTER `teaser`

I'm using Webforms 5.x-2.8

As always, use at your own risk...

Cheers,

Wade

hedroom’s picture

I ran this patch on 5.x-2.9 and it was successful.

The webform.module is the only file that needs to be patched if you have already patched 2.8. webform.submissions.inc did not change with the 2.9 update...

Wade

stacysimpson’s picture

Version: 5.x-1.9 » 6.x-2.9

Has anyone looked at something similar for 6.x?

tim.plunkett’s picture

I wrote the original patch two years ago, and haven't had the time to work on it since then, but I may be revisiting this soon.

izmeez’s picture

subscribing

quicksketch’s picture

Version: 6.x-2.9 »

If updated, make sure it's against the 3.x version. No new features are being added to 2.x.

epersonae2’s picture

Version: » 6.x-3.x-dev

subscribe

fuzzy76’s picture

Subscribing, we would love to see this

hedroom’s picture

StatusFileSize
new153.85 KB

We recently upgraded to Drupal 7.x and needed to add this feature...

Attached is a zip file with the complete edited module and also patch files that can be used on an existing installation (Webform 7.x-3.13).

After copying/patching the module, update.php must be run on your site to add a new field to the webform database table.

Once installed, an "Allow anonymous submissions" checkbox will added to the webform/form settings page. Note: If your form also sends out an e-mail message then the username must be edited, using a custom template, in the webform's e-mail configuration form.

All this patch does is keep the authenticated user's name and IP address out of the submissions database. Editing the e-mail template will keep it from being in the message. Nothing is truly anonymous though... I would assume that a diligent administrator could eek out the IP address of the submitting user from the web logs.

Use this patch at your own risk...

Cheers,

Wade

Anonymous’s picture

@quicksketch - i got here from http://groups.drupal.org/node/199178#comment-657168.

there's interest in using a webform with anonymous data support for DA elections.

this is D6 though - would you be ok if i create a patch for D6 first so we can get this up on d.o. infrastructure, then follow up with a D7 patch?

quicksketch’s picture

All this patch does is keep the authenticated user's name and IP address out of the submissions database.

there's interest in using a webform with anonymous data support for DA elections.

I should note that it's almost trivial for any Drupal developer to simply use hook_webform_submission_presave() to remove IP and user information if you so choose. This doesn't necessarily need to live in Webform core.

nedjo’s picture

@quicksketch: Thanks for the tip. In what ways if any would removing the user information affect functionality? E.g., would this affect the ability to limit users to a single submission (if in fact that's an option with webform)?

quicksketch’s picture

In what ways if any would removing the user information affect functionality? E.g., would this affect the ability to limit users to a single submission (if in fact that's an option with webform)?

This would affect limiting users to a single submission of course, because if you don't have information about them (their IP address or user ID for example), Webform won't be able to use those criteria. If you wanted to be semi-anonymous, I'd recommend making a separate Webform table for NID-UID pairs, to keep track of who had made submissions thus far for a particular node. Of course that's going beyond "trivial" implementation (which is probably why this functionality won't be included directly in the core module either).

Webform does also have the ability to keep track of who has made submission through cookies, but I don't think that cookies are used for authenticated users. I'd be happy to make an adjustment to make it so that cookies could always be used, perhaps by setting a flag in $form_state or similar. A related (but not identical issue) for something like that is over in #246470: Allow cookies as sole voter validation.

liam morland’s picture

Version: 6.x-3.x-dev » 8.x-4.x-dev
Issue summary: View changes
wizonesolutions’s picture

So is the goal here to get this into Webform itself?

Another option is to port https://www.drupal.org/project/webform_anonymous

danchadwick’s picture

Status: Needs work » Fixed

The webform anonymous modules has effectively been included in webform 7.x-4.x. The user needs to log out however. You can't submit an anonymous webform while logged in.

At this point, I don't think any further work on this issue is warranted. If you really want authenticated users to submit anonymously, I suggest you write some custom code that anonymized the submission after they are saved.

danchadwick’s picture

Status: Fixed » Closed (duplicate)
liam morland’s picture

Duplicate of what?

danchadwick’s picture

Duplicate of the issue where Webform Anonymous functionality was incorporated into webform itself.

Differences:
Webform Anonymous is not really anonymous. Any admin can access the data. Webform's functionality is genuinely anonymous.
Webform Anonymous allows "anonymous" submissions while authenticated. Webform requires a log-out.

tim.plunkett’s picture

Status: Closed (duplicate) » Closed (won't fix)

This is not a duplicate. You're deciding to not implement this feature.

danchadwick’s picture

Potato Potaaato. The original request, 8 years old, is more-or-less addressed by the incorporation of the ability to not record submission IP address. That they have to be logged out is a difference. Whatever.