Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Form, make answer field readonly

I'd like to make one of the answer field in the Google form read-only or hidden so that the form recipient won't be able to modify it/ see it .

Is that possible?

here is the context:

So basically my ultimate goal is to leverage Google Forms functionality to send surveys to recipients and track theirs answers in a response spreadsheet.

So far so good...

Now let me introduce you to 2 constraints imposed on me:

  1. Forms sent to recipients need to have some information about the recipient already pre-filled.

  2. The Url provided to each recipient for accessing the form is used to submit and later to update the answers provided on the form.

See the second constraint is tricky...The common thing to do is generate a pre-filled Url send that to the recipient and once they've answered the form you can have a confirmation page where you provide them with a Edit Url that they can use to then update their answers (with last updated answered already pre-filled).

In my case, I cannot provide them with a second url (the Edit Url). It's a one-time thing: I provide one url for each recipient and they'll have to be able to use that same url to answer and update the question-- at a later time if they need.

This functionality isn't supported by Google so I had to write a script that reads from a spreadsheet, use the data in each row to pre-filled a designated form, submit each form then generate an Edit Url for each recipient which I then insert in the "edit url" column of my spreadsheet. I can now give the urls to the recipients and they'll be able to use that url over and over again to update their answers in the survey.

Now to come back to the hidden/readonly field. In my spreadsheet, I have a unique alphanumerical value for each recipient. I want that to be passed to the form so that when they answer (answers are recorded in a response spreadsheet) I'll be able to identify each recipient by this unique "id".

I've written a lot here but I know it's important to give context to people so that they we can all help each other out in a precise and thoughtful way.

like image 341
Cyzanfar Avatar asked Dec 18 '15 21:12

Cyzanfar


3 Answers

The only items that a Form can contain that are NOT for collecting data are:

  • Image items
  • SectionHeader items
  • Video items, and
  • PageBreak items

All other items are intended for input, and cannot be made "read only".

like image 154
Mogsdad Avatar answered Oct 16 '22 21:10

Mogsdad


Update: Google has a limit of 20 triggers per script. This means this solution only works in a scenario where you are generating 20 form responses or less.

Finally, figured this out.

First, create a form with a multiple choice option. This code assumes it's the first item in the form.

var readonlyValue = 'some unique ID';
var form = FormApp.openById('get the ID from the form in edit mode');
var formResponse = form.createResponse();
items = form.getItems();
var readonlyId = items[0].getId();
var readonlyItem = form.getItemById(readonlyId);
readOnlyItem.asMultipleChoiceItem().setChoiceValues([readonlyValue]); 
formResponse.withItemResponse(readonlyItem.asMultipleChoiceItem().createResponse(readonlyValue));      
formUrl = formResponse.submit().toPrefilledUrl();
//formUrl, now has a link to the form with your unique value: pre-filled and pre-selected
like image 37
Rahul Varshney Avatar answered Oct 16 '22 22:10

Rahul Varshney


How to keep a user from seeing parts of the form.

First you create a required question. The required question prevents the user from going to the next page unless the question is answered.

Set up the question, so that the answer to the question ONLY ALLOWS the user to go to the submit page.

So, you have at least 3 pages:

  • 1st page is input
  • an intermediate page that will be hidden
  • last page is the Submit page.

You can set it up, so that it's impossible for the user to get to that intermediate page. You create a required question, that only has one option, to go to the submit page.

And you can prefill that required question, and have a title that states, "For admin purposes only" or something that tells them to just keep moving.

They will click the "Continue" button, it skips the page with the "hidden" input, and goes right to the Submit page.

If they don't click the "Continue" button, but answer the question, then it will also go to the Submit page, because the question is set up to go to the Submit page. Either way, it goes to the Submit page.

like image 24
Alan Wells Avatar answered Oct 16 '22 21:10

Alan Wells