Skip to content

Instantly share code, notes, and snippets.

@rheajt
Created October 9, 2015 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rheajt/e78a7c3d81e0aae1c8e5 to your computer and use it in GitHub Desktop.
Save rheajt/e78a7c3d81e0aae1c8e5 to your computer and use it in GitHub Desktop.
select names for after-school study hall and save to a separate spreadsheet

#After-school Study Hall Names

Every week I have to submit a list of names for the following weeks after-school study program. I am always forgetting, and scrambling at the last minute to remember the names of students who need extra help. I thought it would be easier if I could just tag students as the week goes along. Then when it is time to submit names, I already have a list of names that are generated.

This script could be customized for a number of purposes. Any reason you have to generate lists of names, this script could help you, however, there are a few things that you need to do to customize first.

  1. The 'var fname' should be changed to whatever number column you have your students first name in.
  2. IF you have your students first names and surnames in different columns, you can skip the next step.
  3. If your students first and last names are in the same column, you need to change the '2' in line 5 to a '1'. Also, delete the '+ name[0][1]' that you see in line 7. All this line was doing was concatenating the names that I keep in two separate columns.
  4. The function 'getNextThurs' is of course customized to me, because my after-school session is on Thursdays. To change this to any other day of the week, change the '4's on lines 15-17 to any other number. (Sunday = 0, Monday = 1, Tuesday = 2, ...)
//get the name of the student on the selected row and add them to an Etut list(after school tutoring)
function setEtutList(selected) {
var fname = '2'; //where is the first name
var row = SpreadsheetApp.getActiveRange().getRow();
var name = SpreadsheetApp.getActiveSheet().getRange(row, fname, 1, 2).getValues();
var etutList = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Etut Lists");
etutList.appendRow([getNextThurs().toDateString(), name[0][0] + ' ' + name[0][1]]);
}
//function to get next Thursdays date
function getNextThurs() {
var today = new Date();
if(today > 4) {var nextThursday = new Date(today.getTime() + ((7 - (today.getDay() - 4)) * 24 * 60 * 60 * 1000))};
if(today < 4) {var nextThursday = new Date(today.getTime() + ((7 + (today.getDay() - 4)) * 24 * 60 * 60 * 1000))};
if(today === 4) {var nextThursday = new Date(today.getTime() + (7 * 24 * 60 * 60 * 1000))};
return nextThursday;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment