Real time Google Script Form changes (triggers, onEdit()) - event-handling

How do you change items in Forms from user triggered events during live user interaction with the Form?
I got three ListItems in my form. They all got the same choices to choose from. Users get to choose an activity. If they don't get their choice in the first ListItem they might get it in the second or third.
When a user choose an activity from one of the three ListItems I want to remove this choice of activity from the other two ListItems so that it's not possible to choose the same activity multiple times.
How do you do this? There's an onEdit() function for Spreadsheets but what about Forms?

The live Google Forms cannot be modified based on user interaction.
What you can do is create sections (or branches) and redirect the user to a different section based on the value they've entered in a particular field.

Related

Is there a way to create an output form based on Google Sheets data?

What I want to make
Is this possible?
I'd like to create an output form that reads data from a Google Sheets spreadsheet. In the form, users would enter a few values (entering their name and some ID number, for example) and view the corresponding information in the connected spreadsheet but not any other information in the sheet. Something like an output form in Microsoft Access. I'm hoping there's a way to accomplish this in Google Sheets using existing tools and maybe some scripting.
More generally, though, any way to create this type of 'limited visibility' on a per-user basis for Google Sheets data would be useful. (The 'protect sheet' function in the menu doesn't accomplish this; see below.)
For reference, my specific use case at the moment is as a teacher and wanting a way for students to see specific information related to them from my student information spreadsheet but while not revealing other students' information. I would have a simple form where they enter a name and maybe some personalized code that I give them so they can see their attendance record or something else. For my purposes, I don't need the form to be extremely secure as none of the information is all that sensitive (although more secure is better), but I don't want to be just putting all the information there in front of them by giving them access to the entire sheet.
What I've tried so far
I made a new spreadsheet file with two sheets; one sheet was visible to function as a form, and the second sheet was not visible (which I accomplished via the 'protect' menu option). I used importrange() to read in the relevant data from my primary spreadsheet to the new spreadsheet's non-visible sheet. On the visible sheet, students entered their name from a drop-down and entered their student ID as validation. If the student's name and ID matched, the first sheet did a vlookup() to read in information from the protected sheet and some information from their student record.
Here's what I made, in case my description doesn't make sense: https://drive.google.com/open?id=1cHO2jzMh1mkXvlLh-M4eYqN7v11t95-GnfWqL5IwQ14&authuser=0
This had two problems, one small and one big.
The small problem was that every student could see the "form" sheet at the same time. If two students opened the spreadsheet at the same time they would see any information that the other student had entered. I handled this by writing a simple script to automatically reset the "form's" input cells after 20 seconds. Also, any time the form was opened by a new person, the "form's" output cells were erased. So, obviously not a brilliant solution, but for my purposes, this was mostly good enough.
The big problem was that Google's own preview viewer (built into Google Drive and the like) ignores protected ranges and sheets and displays the entire contents a spreadsheet. (Normally, protected sheets are not visible at all and don't appear in the list of sheets at the bottom of the screen unless the viewer has access to them.)
In my case this meant included the protected one that shouldn't have been visible at all, rendered as if it were a print preview, meaning the students were actually able to view all of the other students' data in one big table.
Are you familiar with Web Apps?
An Apps Script Web App allows you among others to output selected Google Document contents into a browser.
Hereby, you can use the method Session.getActiveUser() to obtain the email of the user and dynamically adjust the data the user is going to obtain in function of his email (BTW, you can also use Session.getActiveUser() in the spreadsheet, to detect the user automatically instead of asking him for his name).
Simple example workflow:
Replace in column A student names through student emails (the Gmail addresses with which the users authenticate their sessions and access Google Sheets)
Bind to the spreadsheet a script with a content similar to the following:
function doGet(){
var ss=SpreadsheetApp.getActive().getSheetByName('Data');
var range=ss.getDataRange();
var values=range.getValues();
var user=Session.getActiveUser();
var output="";
for(var i=1;i<ss.getLastRow();i++){
if(values[i][0]==user){
for(var j=1;j<ss.getLastColumn();j++){
output+=(values[i][j])+" ";
}
}
}
return ContentService.createTextOutput(JSON.stringify(output));
}
Make sure that you have a doGet() function and a return statement.
After running the script once manually to trigger authorization flow, deploy it as a Web App - executing it as User accessing the web app and giving access to Anyone (unless desired otherwise).
Copy the URL of your WebApp and forward it to your student.
When the student open the URL in their browser - they will obtain their results - provided their email is listed in the sheet.
Please note that the code provided is a simple sample, that retrieves
all data and outputs it as a string. Feel free to modify the script
e.g. retrieving only columns of interest and outputting the data as a
html table, rather than a simple string.

Edit Text During Google Slides Presentation

I am trying to build a form in google slides. The form will have specific user inputs like first/last name, email, and zipcode. These inputs will be added to a google spreadsheet after the user submits. It isn't necessary that this happens at that time as most of the time, I will be using this form offline.
I do not wish to use google forms to avoid scrolling or single entry pages. The form would be one slide. How do I create a text box that is editable during a presentation?
You cannot edit when presenting, slides are just pictures/videos. You must go with Google Forms or make your own GUI.

Using ninja forms, how can I persist field values across pages?

I have a form on the home page of quotedjobs.com that I would like to persist the field values of across pages.
For example: A user enters some values in fields, such as job title (textbox), job type (list) and job description (text field). Underneath that I ask users to register on the site, but they have the option to click a link to allow them to login if they are already members.
What I would like to be able to do, is to redirect users to another form that is a copy, but allows them to login instead of register, but keep hold of the values that they entered in the title, type and description form of the previous page so they aren't losing their work.
I have seen the ninja_forms_processing variable in the docs, but I'm not clear on how to use that.
TL;DR - You can't.
As it was slim pickings here, I sent an email over to support. Got this response:
Hello,
At this time this use case is not possible in Ninja Forms. The plugin is currently unable to transfer data from field to field or between forms.
I’m sorry that we do not have a better solution for you at this time.
Thank you,

Split Sonata User Bundle registration form into stages

I'm currently working on a user registration form for a site I'm working on. The site requires a lot of information about users up front, and I'd like to break it down into stages.
The first stage requires the user to put in an identifier in the form of an order number. I would then check the order number exists in the system before making them continue to fill in the rest of the fields. I'm not sure how to go about doing this.
What I've managed so far though is to override the underlying User, RegistrationController and RegistrationFormType and render out a customised view with the relevant form fields.
An overview of the process I'd like would be:
FORM: ask for order number
process form and check order number exists (if not go back to 1)
FORM: ask for user information
process user information and store
complete
Simplest way of doing it will be to override registration template, and hide all fields except those you wanna show in first.
And than add some js validation rules, - to show up parts of form based on values prefilled by user. In that case you do not need to rework Sonata registration form, but for user experience it will be the same.

Symfony2 - Showing a page for a user to confirm input form values

I have a long form that an user has to fill. After the user has clicked submit, I have to show a page with the information the user has filled in the form so that he can check that everything is correct before doing any further processing (i.e., he has to press another submit button or a back button if he detects an error).
Is there an easy way to do this? Is there a better way than creating a new form with hidden values equal to the values submitted in the previous form?
Would it be okay if I just store the information in a session variable and then process it if the user confirms?
You could skin that cat many ways, here's a couple of ideas:
Add a non-mapped confirm input (like a checkbox) to your form. On initial form render with no POST, hide the input. When you get a POST, show the checkbox input & some additional information (please review your data & check to confirm all is OK etc). Don't validate the form or save your data until the confirm input has been checked. You don't need to mess about with hidden fields, the one form will do the job for you.
Save the entity and give it a property e.g. isApproved, that way you can show the data easily & if the user needs to edit, re-use your form. When the user approves the information set isApproved to true. Don't perform any actions on any entities that have isApproved == false. Cons are you then have to manage an isApproved state for an entity.