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.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | webform_patch.zip | 153.85 KB | hedroom |
| #4 | webform.module.patch | 3.37 KB | hedroom |
| #4 | webforms_submissions.patch | 1.3 KB | hedroom |
| webform_report_inc.patch | 1.75 KB | tim.plunkett | |
| webform_module.patch | 4.2 KB | tim.plunkett |
Comments
Comment #1
SabbeRubbish commentedHi,
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.
Comment #2
quicksketchSo 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:
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.
Comment #3
felipe commentedHi 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.
Comment #4
hedroom commentedI 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
Comment #5
hedroom commentedI 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
Comment #6
stacysimpson commentedHas anyone looked at something similar for 6.x?
Comment #7
tim.plunkettI 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.
Comment #8
izmeez commentedsubscribing
Comment #9
quicksketchIf updated, make sure it's against the 3.x version. No new features are being added to 2.x.
Comment #10
epersonae2 commentedsubscribe
Comment #11
fuzzy76 commentedSubscribing, we would love to see this
Comment #12
hedroom commentedWe 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
Comment #13
Anonymous (not verified) commented@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?
Comment #14
quicksketchI 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.
Comment #15
nedjo@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)?
Comment #16
quicksketchThis 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.
Comment #17
liam morlandComment #18
wizonesolutionsSo is the goal here to get this into Webform itself?
Another option is to port https://www.drupal.org/project/webform_anonymous
Comment #19
danchadwick commentedThe 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.
Comment #20
danchadwick commentedComment #21
liam morlandDuplicate of what?
Comment #22
danchadwick commentedDuplicate 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.
Comment #23
tim.plunkettThis is not a duplicate. You're deciding to not implement this feature.
Comment #24
danchadwick commentedPotato 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.