This script was written for Thornhill Secondary School to filter and count votes for the Board of Student Senator elections. The following instructions are specific to Thornhill Secondary School, and may not be applicable for all use.
Before following these instructions (if applicable), make a copy of the Google Sheet. Copy the newly made form & sheet into another folder, then open the new sheet and follow these instructions. This Google Sheet is only accessible for Election Committee members at TSS. To create your own, follow the steps in section 3.3 first!
- Edit the attached Google Form to include the senator/executive positions. Make sure to enclose the position name in quotation marks. For example: Vote for up to two candidates for "GRADE 11 SENATOR"

- To allow certain students to vote, paste in their GAPPS student ID (not including the email address, just the number) in the “Student No.” column of the "Allowed Students" tab.

- The form is now ready and should be tested before use. Follow the testing procedure outlined in 2.1.
- Once the responses/ballots have been recorded, press the "Count Ballots" button under "BOSS Election" in the toolbar. It may ask you to authorize, click accept. Make sure the script is only able to access the current spreadsheet, otherwise it is a sign that the script has been tampered with, and you should not use it.

- The results should be recorded in a new tab called "Results".

Why is testing necessary?
Testing should be completed before any election to ensure that no part of the script has been broken or changed. Some sources of error could be people editing the script, or due to changes made by Google in their systems. Make sure to test the system thoroughly before use.
- Make sure the final form is ready before testing, follow the steps in section 1.1. This is to ensure that no error is introduced while editing/modifying.
- Make a copy of the Sheet and Form and prefix it with "[Testing]". This is to avoid confusion.
- Share the copied sheet with a few testers, and ask them to select random choices for each candidate. Make sure to include their student numbers in the "Allowed Students" tab.
- Click the "Count Ballots" button, and make sure the results are as expected.
This section is to guarantee the reproducibility of this system. In normal circumstances, this should not be required. But in cases of upgrading/fixing bugs, these instructions can come in handy.
To successfully set up this project, these tools are required:
- Node.js (https://nodejs.org/en/download/)
- clasp by Google (https://github.com/google/clasp)
- (optional, but recommended) Visual Studio Code (https://code.visualstudio.com/)
- (optional) git-cli (https://git-scm.com/downloads)
Follow these steps to set up the election software.
- Download and install Node.js
- Install clasp with the command
npm install -g @google/clasp - Clone or Download this repository into a folder
- In the folder, run
npm i -S @types/google-apps-script - On the first time, you need to login to your Google account with the command
clasp login - Run
clasp create <name>and selectsheetsin the dropdown. - Open the sheets link shown in the console

- In the sheets, create a linked form:

- On the bottom, rename the linked form to
Responsesand create a new tab calledAllowed Students. These must be exact for the script to work properly.
- The script is now ready, you can update
sheets.tswhich is the main file, and compile/upload it with the commandclasp push - Follow the instructions in 1.1 to operate the election.