This is the full example that Stefan Muntwyler developed for his class at UNIS Hanoi, modified by both Stefan and Paul Swanson for demonstration purposes.Click here to view and then copy the spreadsheet.
Note that there are six functions in this script:
- onSubmit – this is what is triggered on form submission, and contains the main structure: build message, append message, send message
- buildMessage – this function uses a helper function, convertToList, to format the form response data and build a message out of it
- convertToList – this helper function takes the comma separated values and converts them into a nicely formatted list
- appendToDoc – this function opens up the student’s Google Doc and attaches the message to it
- emailStudent – this function creates an email based on the feedback message and then emails it to the student
The main function, onSubmit, does something that we haven’t see yet: it calls a function and then sets the RETURN value equal to a variable.
Just as you can pass parameters to a function, you can also RETURN values back to the original CALL. These return values can be set to variables, or can be used to call further methods, depending on the needs of the programmer.
THAT’S IT! Congratulations – you now have a fully functional Form/Sheet/Script system to automate your formative feedback with your students!
Google Scripts Lessons 1-10
Click on a lesson below for a written tutorial demonstrating the lesson.
- Lesson 1 – “Hello World!”
- Lesson 2 – Challenge: Calling Functions
- Lesson 3 – Variables
- Lesson 4 – Variable Passing
- Lesson 5 – Variable Passing Challenge
- Lesson 6 – Arrays of Variables
- Lesson 7 – Modifying a Google Doc
- Lesson 8 – Modify Doc and Send Email
- Lesson 9 – Simple Feedback script
- Lesson 10 – Full-scale feedback