Reputation: 11
First time using Stack Overflow so excuse me if I'm doing this wrong
I'm doing a school project and I want to make a google form with 8 different yes or no questions that lead to a specific page depending on the combination of answers. I used truth tables and logic to find what combinations of answers lead to what results. For example, the logic expression A'B'E'F ( C' + D )
leads to a result about cable trays for cable management. However, I'm trying to find a way to actually do this.
I was wondering if anyone knows if it's possible to use Google's Apps Scripts to do this. I'm just looking for a way to turn a yes/no answer in a form into a true/false variable that can be used to send to a specific page.
I'm trying to do it in google forms but am open to other sites.
Upvotes: 1
Views: 846
Reputation: 5953
Opening an URL from a form submission is not possible in Apps Script because during form submission, the form editor is not open.
Based on Class Ui:
A script can only interact with the UI for the current instance of an open editor, and only if the script is container-bound to the editor.
One workaround I could suggest is to send an email to the respondent with the url link.
Sample Code:
function onSubmitForm(e) {
var response = e.response;
//Get item responses
var items =response.getItemResponses();
//Get respondent's email
var email = response.getRespondentEmail();
var url;
var A = [];
//Convert responses Yes/No to 1/0
for(var i = 0; i<items.length; i++){
A.push(items[i].getResponse()=="Yes"?1:0);
}
Logger.log(A);
Logger.log(!A[0] * !A[1] * !A[4] * A[5] * (!A[2] + A[3]));
//Check if logical expression was satisfied A'B'E'F ( C' + D )
if(!A[0] * !A[1] * !A[4] * A[5] * (!A[2] + A[3])){
url = "https://www.youtube.com/?hl=en&gl=PH";
}else{
url = "https://google.com";
}
//Send Email with the link
var subject = "Test Email";
var body = "Please refer to this link: "+url;
MailApp.sendEmail(email,subject,body);
}
Sample Trigger Configuration:
Upvotes: 1