-
Notifications
You must be signed in to change notification settings - Fork 0
Datathon ‐ Google Forms
To collect responses from our Datathon Participants and Volunteers, we make use of the following Google Forms to collect and process their response. These forms will most likely be created by the Events Team, but the Web Dev will assist in the deployment of the Participant & Volunteer Registration Forms. There are certain requirements and configurations to consider with these forms:
This will be the first form, that can be filled out by a potential participant. The Web Dev will need to ensure the following fields are being collected with the appropriate response validations.
These fields must exist on the forms, with the correct level of Response Validation as indicated in the table below.
| Form Field | Response Validation |
|---|---|
| First Name | N/A |
| Last Name | N/A |
Check if the input is Text and Email else provide this message: Invalid email
|
|
| Phone Number | Use a Regex to see if the input matches ^[\+]?[(]?[0-9]{3}[)]?[0-9]{3}[0-9]{4,6}$ else provide this message: Invalid Phone Number
|
| School | Only allow for one selection else provide this message: Select only 1 from above
|
| Country of Residence | Only allow for one selection else provide this message: Select only 1 from above
|
| Dietary Restrictions | N/A |
To collect the latest response from the form and store it on MongoDB Atlas, we will set a WebHook Request that sends a POST request to our server to save the response.
This is an example implementation used for the 2024 Datathon Form.
var POST_URL = "https://datathon-ops.ds3utsc.com/api/registration"; // URL of that accepts a POST Request
const VALIDATION_SECRET = "<insert-validation-secret>"; // Used to verify if requests are authentic or not
var payload = {};
function onSubmit(e) {
const form = FormApp.getActiveForm();
const allResponses = form.getResponses();
const latestResponse = allResponses[allResponses.length - 1];
const response = latestResponse.getItemResponses();
// Collects the specific fields needed from the submission
for (var i = 0; i < response.length; i++) {
var question = response[i].getItem().getTitle();
var answer = response[i].getResponse();
switch (question) {
case "📛 First Name":
payload["firstName"] = answer;
break;
case "📛 Last Name":
payload["lastName"] = answer;
break;
case "📧 Email":
payload["email"] = answer;
break;
case "🏫 School":
payload["school"] = answer[0];
break;
case "📞 Phone Number":
payload["phoneNum"] = answer;
break;
case "🌎 Country of Residence":
payload["countryOfResidence"] = answer[0];
break;
case "🥞 Do you have any dietary restrictions?":
payload["dietaryRestrictions"] = answer;
break;
}
}
// POST Request
var options = {
method: "post",
headers: {
"ds3-secret": VALIDATION_SECRET,
},
contentType: "application/json",
payload: JSON.stringify(payload),
};
UrlFetchApp.fetch(POST_URL, options);
}- Open Google Forms and navigate to the Registration Form.
- Click on the More button (three vertical dots) in the top-right corner of the screen.
- Select Script editor from the dropdown menu.
- Create a new App Script File by clicking the + Button.
- Implement the above code with any necessary changes and save changes.
- Move over to the Side Menu and click the Option called Trigger.
- Click Add Trigger.
- When the Modal pops up, ensure the options are as follows and click Save to deploy it.

- Open Google Forms and navigate to the Registration Form.
- Click on the More button (three vertical dots) in the top-right corner of the screen.
- Select Script editor from the dropdown menu.
- Move over to the Side Menu and click the Option called Trigger.
- Hover over the trigger and click on the More button (three vertical dots) on the right-hand side
- Select Delete Trigger
This will be the form that will be filled out by volunteers. The Web Dev will need to ensure the following fields are being collected with the appropriate response validations. Once enough volunteers exist, the Web Dev Team will require a list of Emails from the Events Team to create Login Credentials for each volunteer to access the Admin Site for QR Code Scanning.
These fields must exist on the form, with the correct level of Response Validation as indicated in the table below.
| Form Field | Response Validation |
|---|---|
Check if the input is Text and Email else provide this message: Invalid email
|