-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgoogle-forms-creator
More file actions
30 lines (26 loc) · 1.12 KB
/
google-forms-creator
File metadata and controls
30 lines (26 loc) · 1.12 KB
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
/*
This function can be ran from importing the CSV into Google Sheets
It will turn the entries into a Google Form with the title and all added text and a vote option from 1 to 5.
Do not forget to change `var lines`
*
function myFunction() {
// change me to the number of lines
var lines = 40;
var form = FormApp.create('New Form');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var rangeData = sheet.getDataRange();
var searchRange = sheet.getRange(1,1, lines);
// Get array of values in the search Range
var rangeValues = searchRange.getValues();
// Loop through array and if condition met, add relevant
// background color.
for ( i = 1; i < lines; i++){
form.addScaleItem()
.setTitle(sheet.getRange(i, 2).getValues()[0][0] + " - " + sheet.getRange(i, 3).getValues()[0][0])
.setHelpText(sheet.getRange(i, 4).getValues()[0][0] + "\n" + sheet.getRange(i, 5).getValues()[0][0] + "\n" + sheet.getRange(i, 6).getValues()[0][0])
.setBounds(1, 5);
};
Logger.log('Published URL: ' + form.getPublishedUrl());
Logger.log('Editor URL: ' + form.getEditUrl());
}