-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_form.gs
52 lines (44 loc) · 1.61 KB
/
create_form.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function createForms() {
var files = DriveApp.getFiles();
while (files.hasNext()) {
var file = files.next();
var name = file.getName();
var week = 0;
for (week = 1; week < 18; week++) {
var sched = name.search("Week " + week + " - sched.csv");
if (sched == 0) {
break;
}
}
if (sched == 0) {
var form = FormApp.create("Week" + week);
var sheet = SpreadsheetApp.open(file).getSheets()[0];
var range = sheet.getDataRange();
var values = range.getValues();
var num_games = values[0].length;
form.setTitle('Week ' + week + " Picks")
.setDescription('NFL Picks for Week ' + week)
.setConfirmationMessage('Good Luck!')
.setAllowResponseEdits(false)
.setAcceptingResponses(true);
var item = form.addMultipleChoiceItem();
item.setChoices([
item.createChoice('Curt'),
item.createChoice('Amy'),
item.createChoice('Laura'),
item.createChoice('Tyler'),
item.createChoice('Katie'),
item.createChoice('Troy'),
item.createChoice('Chris'),
item.createChoice('Sam'),
]);
for (var i = 0; i < num_games; i++) {
var item = form.addMultipleChoiceItem();
item.setChoices([
item.createChoice(values[0][i]),
item.createChoice(values[1][i])
]);
}
}
}
};