forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
google-apps-script.forms.d.ts
754 lines (726 loc) · 29.6 KB
/
google-apps-script.forms.d.ts
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
// Type definitions for Google Apps Script 2015-11-12
// Project: https://developers.google.com/apps-script/
// Definitions by: motemen <https://github.com/motemen/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="google-apps-script.types.d.ts" />
/// <reference path="google-apps-script.base.d.ts" />
declare namespace GoogleAppsScript {
export module Forms {
/**
* An enum representing the supported types of image alignment. Alignment types can be accessed from
* FormApp.Alignment.
*
* // Open a form by ID and add a new image item with alignment
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var img = UrlFetchApp.fetch('https://www.google.com/images/srpr/logo4w.png');
* form.addImageItem()
* .setImage(img)
* .setAlignment(FormApp.Alignment.CENTER);
*/
export enum Alignment { LEFT, CENTER, RIGHT }
/**
* A question item that allows the respondent to select one or more checkboxes, as well as an
* optional "other" field. Items can be accessed or created from a Form.
*
* // Open a form by ID and add a new checkbox item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addCheckboxItem();
* item.setTitle('What condiments would you like on your hot dog?')
* .setChoices([
* item.createChoice('Ketchup'),
* item.createChoice('Mustard'),
* item.createChoice('Relish')
* ])
* .showOtherOption(true);
*/
export interface CheckboxItem {
createChoice(value: string): Choice;
createResponse(responses: String[]): ItemResponse;
duplicate(): CheckboxItem;
getChoices(): Choice[];
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
hasOtherOption(): boolean;
isRequired(): boolean;
setChoiceValues(values: String[]): CheckboxItem;
setChoices(choices: Choice[]): CheckboxItem;
setHelpText(text: string): CheckboxItem;
setRequired(enabled: boolean): CheckboxItem;
setTitle(title: string): CheckboxItem;
showOtherOption(enabled: boolean): CheckboxItem;
}
/**
* A single choice associated with a type of Item that supports choices, like
* CheckboxItem, ListItem, or MultipleChoiceItem.
*
* // Create a new form and add a multiple-choice item.
* var form = FormApp.create('Form Name');
* var item = form.addMultipleChoiceItem();
* item.setTitle('Do you prefer cats or dogs?')
* .setChoices([
* item.createChoice('Cats', FormApp.PageNavigationType.CONTINUE),
* item.createChoice('Dogs', FormApp.PageNavigationType.RESTART)
* ]);
*
* // Add another page because navigation has no effect on the last page.
* form.addPageBreakItem().setTitle('You chose well!');
*
* // Log the navigation types that each choice results in.
* var choices = item.getChoices();
* for (var i = 0; i < choices.length; i++) {
* Logger.log('If the respondent chooses "%s", the form will %s.',
* choices[i].getValue(),
* choices[i].getPageNavigationType());
* }
*/
export interface Choice {
getGotoPage(): PageBreakItem;
getPageNavigationType(): PageNavigationType;
getValue(): string;
}
/**
* A question item that allows the respondent to indicate a date. Items can be accessed or created
* from a Form.
*
* // Open a form by ID and add a new date item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addDateItem();
* item.setTitle('When were you born?');
*/
export interface DateItem {
createResponse(response: Date): ItemResponse;
duplicate(): DateItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
includesYear(): boolean;
isRequired(): boolean;
setHelpText(text: string): DateItem;
setIncludesYear(enableYear: boolean): DateItem;
setRequired(enabled: boolean): DateItem;
setTitle(title: string): DateItem;
}
/**
* A question item that allows the respondent to indicate a date and time. Items can be accessed or
* created from a Form.
*
* // Open a form by ID and add a new date-time item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addDateTimeItem();
* item.setTitle('When do you want to meet?');
*/
export interface DateTimeItem {
createResponse(response: Date): ItemResponse;
duplicate(): DateTimeItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
includesYear(): boolean;
isRequired(): boolean;
setHelpText(text: string): DateTimeItem;
setIncludesYear(enableYear: boolean): DateTimeItem;
setRequired(enabled: boolean): DateTimeItem;
setTitle(title: string): DateTimeItem;
}
/**
* An enum representing the supported types of form-response destinations. All forms, including
* those that do not have a destination set explicitly,
* save
* a copy of responses in the form's response store. Destination types can be accessed from
* FormApp.DestinationType.
*
* // Open a form by ID and create a new spreadsheet.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var ss = SpreadsheetApp.create('Spreadsheet Name');
*
* // Update the form's response destination.
* form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
*/
export enum DestinationType { SPREADSHEET }
/**
* A question item that allows the respondent to indicate a length of time. Items can be accessed or
* created from a Form.
*
* // Open a form by ID and add a new duration item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addDurationItem();
* item.setTitle('How long can you hold your breath?');
*/
export interface DurationItem {
createResponse(hours: Integer, minutes: Integer, seconds: Integer): ItemResponse;
duplicate(): DurationItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
isRequired(): boolean;
setHelpText(text: string): DurationItem;
setRequired(enabled: boolean): DurationItem;
setTitle(title: string): DurationItem;
}
/**
* A form that contains overall properties (such as title, settings, and where responses are stored)
* and items (which includes question items like checkboxes and layout items like page breaks).
* Forms can be accessed or created from FormApp.
*
* // Open a form by ID and create a new spreadsheet.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var ss = SpreadsheetApp.create('Spreadsheet Name');
*
* // Update form properties via chaining.
* form.setTitle('Form Name')
* .setDescription('Description of form')
* .setConfirmationMessage('Thanks for responding!')
* .setAllowResponseEdits(true)
* .setAcceptingResponses(false);
*
* // Update the form's response destination.
* form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
*/
export interface Form {
addCheckboxItem(): CheckboxItem;
addDateItem(): DateItem;
addDateTimeItem(): DateTimeItem;
addDurationItem(): DurationItem;
addEditor(emailAddress: string): Form;
addEditor(user: Base.User): Form;
addEditors(emailAddresses: String[]): Form;
addGridItem(): GridItem;
addImageItem(): ImageItem;
addListItem(): ListItem;
addMultipleChoiceItem(): MultipleChoiceItem;
addPageBreakItem(): PageBreakItem;
addParagraphTextItem(): ParagraphTextItem;
addScaleItem(): ScaleItem;
addSectionHeaderItem(): SectionHeaderItem;
addTextItem(): TextItem;
addTimeItem(): TimeItem;
addVideoItem(): VideoItem;
canEditResponse(): boolean;
collectsEmail(): boolean;
createResponse(): FormResponse;
deleteAllResponses(): Form;
deleteItem(index: Integer): void;
deleteItem(item: Item): void;
getConfirmationMessage(): string;
getCustomClosedFormMessage(): string;
getDescription(): string;
getDestinationId(): string;
getDestinationType(): DestinationType;
getEditUrl(): string;
getEditors(): Base.User[];
getId(): string;
getItemById(id: Integer): Item;
getItems(): Item[];
getItems(itemType: ItemType): Item[];
getPublishedUrl(): string;
getResponse(responseId: string): FormResponse;
getResponses(): FormResponse[];
getResponses(timestamp: Date): FormResponse[];
getShuffleQuestions(): boolean;
getSummaryUrl(): string;
getTitle(): string;
hasLimitOneResponsePerUser(): boolean;
hasProgressBar(): boolean;
hasRespondAgainLink(): boolean;
isAcceptingResponses(): boolean;
isPublishingSummary(): boolean;
moveItem(from: Integer, to: Integer): Item;
moveItem(item: Item, toIndex: Integer): Item;
removeDestination(): Form;
removeEditor(emailAddress: string): Form;
removeEditor(user: Base.User): Form;
requiresLogin(): boolean;
setAcceptingResponses(enabled: boolean): Form;
setAllowResponseEdits(enabled: boolean): Form;
setCollectEmail(collect: boolean): Form;
setConfirmationMessage(message: string): Form;
setCustomClosedFormMessage(message: string): Form;
setDescription(description: string): Form;
setDestination(type: DestinationType, id: string): Form;
setLimitOneResponsePerUser(enabled: boolean): Form;
setProgressBar(enabled: boolean): Form;
setPublishingSummary(enabled: boolean): Form;
setRequireLogin(requireLogin: boolean): Form;
setShowLinkToRespondAgain(enabled: boolean): Form;
setShuffleQuestions(shuffle: boolean): Form;
setTitle(title: string): Form;
shortenFormUrl(url: string): string;
}
/**
* Allows a script to open existing Forms or create new ones.
*
* // Open a form by ID.
* var existingForm = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
*
* // Create and open a form.
* var newForm = FormApp.create('Form Name');
*/
export interface FormApp {
Alignment: Alignment
DestinationType: DestinationType
ItemType: ItemType
PageNavigationType: PageNavigationType
create(title: string): Form;
getActiveForm(): Form;
getUi(): Base.Ui;
openById(id: string): Form;
openByUrl(url: string): Form;
}
/**
* A response to the form as a whole. Form responses have three main uses: they contain the answers
* submitted by a respondent (see getItemResponses(), they can be used to programmatically
* respond to the form (see withItemResponse(response) and submit()), and they
* can be used as a template to create a URL for the form with pre-filled answers. Form responses
* can be created or accessed from a Form.
*
* // Open a form by ID and log the responses to each question.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var formResponses = form.getResponses();
* for (var i = 0; i < formResponses.length; i++) {
* var formResponse = formResponses[i];
* var itemResponses = formResponse.getItemResponses();
* for (var j = 0; j < itemResponses.length; j++) {
* var itemResponse = itemResponses[j];
* Logger.log('Response #%s to the question "%s" was "%s"',
* (i + 1).toString(),
* itemResponse.getItem().getTitle(),
* itemResponse.getResponse());
* }
* }
*/
export interface FormResponse {
getEditResponseUrl(): string;
getId(): string;
getItemResponses(): ItemResponse[];
getRespondentEmail(): string;
getResponseForItem(item: Item): ItemResponse;
getTimestamp(): Date;
submit(): FormResponse;
toPrefilledUrl(): string;
withItemResponse(response: ItemResponse): FormResponse;
}
/**
* A question item, presented as a grid of columns and rows, that allows the respondent to select
* one choice per row from a sequence of radio buttons. Items can be accessed or created from a
* Form.
*
* // Open a form by ID and add a new grid item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addGridItem();
* item.setTitle('Rate your interests')
* .setRows(['Cars', 'Computers', 'Celebrities'])
* .setColumns(['Boring', 'So-so', 'Interesting']);
*/
export interface GridItem {
createResponse(responses: String[]): ItemResponse;
duplicate(): GridItem;
getColumns(): String[];
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getRows(): String[];
getTitle(): string;
getType(): ItemType;
isRequired(): boolean;
setColumns(columns: String[]): GridItem;
setHelpText(text: string): GridItem;
setRequired(enabled: boolean): GridItem;
setRows(rows: String[]): GridItem;
setTitle(title: string): GridItem;
}
/**
* A layout item that displays an image. Items can be accessed or created from a Form.
*
* // Open a form by ID and add a new image item
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var img = UrlFetchApp.fetch('https://www.google.com/images/srpr/logo4w.png');
* form.addImageItem()
* .setTitle('Google')
* .setHelpText('Google Logo') // The help text is the image description
* .setImage(img);
*/
export interface ImageItem {
duplicate(): ImageItem;
getAlignment(): Alignment;
getHelpText(): string;
getId(): Integer;
getImage(): Base.Blob;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
getWidth(): Integer;
setAlignment(alignment: Alignment): ImageItem;
setHelpText(text: string): ImageItem;
setImage(image: Base.BlobSource): ImageItem;
setTitle(title: string): ImageItem;
setWidth(width: Integer): ImageItem;
}
/**
* A generic form item that contains properties common to all items, such as title and help text.
* Items can be accessed or created from a Form.
*
* To operate on type-specific properties, use getType() to check the item's
* ItemType, then cast the item to the
* appropriate class using a method like asCheckboxItem().
*
* // Create a new form and add a text item.
* var form = FormApp.create('Form Name');
* form.addTextItem();
*
* // Access the text item as a generic item.
* var items = form.getItems();
* var item = items[0];
*
* // Cast the generic item to the text-item class.
* if (item.getType() == 'TEXT') {
* var textItem = item.asTextItem();
* textItem.setRequired(false);
* }
*/
export interface Item {
asCheckboxItem(): CheckboxItem;
asDateItem(): DateItem;
asDateTimeItem(): DateTimeItem;
asDurationItem(): DurationItem;
asGridItem(): GridItem;
asImageItem(): ImageItem;
asListItem(): ListItem;
asMultipleChoiceItem(): MultipleChoiceItem;
asPageBreakItem(): PageBreakItem;
asParagraphTextItem(): ParagraphTextItem;
asScaleItem(): ScaleItem;
asSectionHeaderItem(): SectionHeaderItem;
asTextItem(): TextItem;
asTimeItem(): TimeItem;
asVideoItem(): VideoItem;
duplicate(): Item;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
setHelpText(text: string): Item;
setTitle(title: string): Item;
}
/**
* A response to one question item within a form. Item responses can be accessed from
* FormResponse and created from any Item that asks the respondent to answer a
* question.
*
* // Open a form by ID and log the responses to each question.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var formResponses = form.getResponses();
* for (var i = 0; i < formResponses.length; i++) {
* var formResponse = formResponses[i];
* var itemResponses = formResponse.getItemResponses();
* for (var j = 0; j < itemResponses.length; j++) {
* var itemResponse = itemResponses[j];
* Logger.log('Response #%s to the question "%s" was "%s"',
* (i + 1).toString(),
* itemResponse.getItem().getTitle(),
* itemResponse.getResponse());
* }
* }
*/
export interface ItemResponse {
getItem(): Item;
getResponse(): Object;
}
/**
* An enum representing the supported types of form items. Item types can be accessed from
* FormApp.ItemType.
*
* // Open a form by ID and add a new section header.
* var form = FormApp.create('Form Name');
* var item = form.addSectionHeaderItem();
* item.setTitle('Title of new section');
*
* // Check the item type.
* if (item.getType() == FormApp.ItemType.SECTION_HEADER) {
* item.setHelpText('Description of new section.');
* }
*/
export enum ItemType { CHECKBOX, DATE, DATETIME, DURATION, GRID, IMAGE, LIST, MULTIPLE_CHOICE, PAGE_BREAK, PARAGRAPH_TEXT, SCALE, SECTION_HEADER, TEXT, TIME }
/**
* A question item that allows the respondent to select one choice from a drop-down list. Items can
* be accessed or created from a Form.
*
* // Open a form by ID and add a new list item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addListItem();
* item.setTitle('Do you prefer cats or dogs?')
* .setChoices([
* item.createChoice('Cats'),
* item.createChoice('Dogs')
* ]);
*/
export interface ListItem {
createChoice(value: string): Choice;
createChoice(value: string, navigationItem: PageBreakItem): Choice;
createChoice(value: string, navigationType: PageNavigationType): Choice;
createResponse(response: string): ItemResponse;
duplicate(): ListItem;
getChoices(): Choice[];
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
isRequired(): boolean;
setChoiceValues(values: String[]): ListItem;
setChoices(choices: Choice[]): ListItem;
setHelpText(text: string): ListItem;
setRequired(enabled: boolean): ListItem;
setTitle(title: string): ListItem;
}
/**
* A question item that allows the respondent to select one choice from a list of radio buttons or
* an optional "other" field. Items can be accessed or created from a Form.
*
* // Open a form by ID and add a new multiple choice item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addMultipleChoiceItem();
* item.setTitle('Do you prefer cats or dogs?')
* .setChoices([
* item.createChoice('Cats'),
* item.createChoice('Dogs')
* ])
* .showOtherOption(true);
*/
export interface MultipleChoiceItem {
createChoice(value: string): Choice;
createChoice(value: string, navigationItem: PageBreakItem): Choice;
createChoice(value: string, navigationType: PageNavigationType): Choice;
createResponse(response: string): ItemResponse;
duplicate(): MultipleChoiceItem;
getChoices(): Choice[];
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
hasOtherOption(): boolean;
isRequired(): boolean;
setChoiceValues(values: String[]): MultipleChoiceItem;
setChoices(choices: Choice[]): MultipleChoiceItem;
setHelpText(text: string): MultipleChoiceItem;
setRequired(enabled: boolean): MultipleChoiceItem;
setTitle(title: string): MultipleChoiceItem;
showOtherOption(enabled: boolean): MultipleChoiceItem;
}
/**
* A layout item that marks the start of a page. Items can be accessed or
* created from a Form.
*
* // Create a form and add three page-break items.
* var form = FormApp.create('Form Name');
* var pageTwo = form.addPageBreakItem().setTitle('Page Two');
* var pageThree = form.addPageBreakItem().setTitle('Page Three');
*
* // Make the first two pages navigate elsewhere upon completion.
* pageTwo.setGoToPage(pageThree); // At end of page one (start of page two), jump to page three
* pageThree.setGoToPage(FormApp.PageNavigationType.RESTART); // At end of page two, restart form
*/
export interface PageBreakItem {
duplicate(): PageBreakItem;
getGoToPage(): PageBreakItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getPageNavigationType(): PageNavigationType;
getTitle(): string;
getType(): ItemType;
setGoToPage(goToPageItem: PageBreakItem): PageBreakItem;
setGoToPage(navigationType: PageNavigationType): PageBreakItem;
setHelpText(text: string): PageBreakItem;
setTitle(title: string): PageBreakItem;
}
/**
* An enum representing the supported types of page navigation. Page navigation types can be
* accessed from FormApp.PageNavigationType.
*
* The page navigation occurs after the respondent completes a page that contains the option, and
* only if the respondent chose that option. If the respondent chose multiple options with
* page-navigation instructions on the same page, only the last navigation option has any effect.
* Page navigation also has no effect on the last page of a form.
* Choices that use page navigation cannot be combined in the same item with choices that do not
* use page navigation.
*
* // Create a form and add a new multiple-choice item and a page-break item.
* var form = FormApp.create('Form Name');
* var item = form.addMultipleChoiceItem();
* var pageBreak = form.addPageBreakItem();
*
* // Set some choices with go-to-page logic.
* var rightChoice = item.createChoice('Vanilla', FormApp.PageNavigationType.SUBMIT);
* var wrongChoice = item.createChoice('Chocolate', FormApp.PageNavigationType.RESTART);
*
* // For GO_TO_PAGE, just pass in the page break item. For CONTINUE (normally the default), pass in
* // CONTINUE explicitly because page navigation cannot be mixed with non-navigation choices.
* var iffyChoice = item.createChoice('Peanut', pageBreak);
* var otherChoice = item.createChoice('Strawberry', FormApp.PageNavigationType.CONTINUE);
* item.setChoices([rightChoice, wrongChoice, iffyChoice, otherChoice]);
*/
export enum PageNavigationType { CONTINUE, GO_TO_PAGE, RESTART, SUBMIT }
/**
* A question item that allows the respondent to enter a block of text. Items can be accessed or
* created from a Form.
*
* // Open a form by ID and add a new paragraph text item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addParagraphTextItem();
* item.setTitle('What is your address?');
*/
export interface ParagraphTextItem {
createResponse(response: string): ItemResponse;
duplicate(): ParagraphTextItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
isRequired(): boolean;
setHelpText(text: string): ParagraphTextItem;
setRequired(enabled: boolean): ParagraphTextItem;
setTitle(title: string): ParagraphTextItem;
}
/**
* A question item that allows the respondent to choose one option from a numbered sequence of radio
* buttons. Items can be accessed or created from a Form.
*
* // Open a form by ID and add a new scale item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addScaleItem();
* item.setTitle('Pick a number between 1 and 10')
* .setBounds(1, 10);
*/
export interface ScaleItem {
createResponse(response: Integer): ItemResponse;
duplicate(): ScaleItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getLeftLabel(): string;
getLowerBound(): Integer;
getRightLabel(): string;
getTitle(): string;
getType(): ItemType;
getUpperBound(): Integer;
isRequired(): boolean;
setBounds(lower: Integer, upper: Integer): ScaleItem;
setHelpText(text: string): ScaleItem;
setLabels(lower: string, upper: string): ScaleItem;
setRequired(enabled: boolean): ScaleItem;
setTitle(title: string): ScaleItem;
}
/**
* A layout item that visually indicates the start of a section. Items can be accessed or created
* from a Form.
*
* // Open a form by ID and add a new section header.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addSectionHeaderItem();
* item.setTitle('Title of new section');
*/
export interface SectionHeaderItem {
duplicate(): SectionHeaderItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
setHelpText(text: string): SectionHeaderItem;
setTitle(title: string): SectionHeaderItem;
}
/**
* A question item that allows the respondent to enter a single line of text. Items can be accessed
* or created from a Form.
*
* // Open a form by ID and add a new text item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addTextItem();
* item.setTitle('What is your name?');
*/
export interface TextItem {
createResponse(response: string): ItemResponse;
duplicate(): TextItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
isRequired(): boolean;
setHelpText(text: string): TextItem;
setRequired(enabled: boolean): TextItem;
setTitle(title: string): TextItem;
}
/**
* A question item that allows the respondent to indicate a time of day. Items can be accessed or
* created from a Form.
*
* // Open a form by ID and add a new time item.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* var item = form.addTimeItem();
* item.setTitle('What time do you usually wake up in the morning?');
*/
export interface TimeItem {
createResponse(hour: Integer, minute: Integer): ItemResponse;
duplicate(): TimeItem;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
isRequired(): boolean;
setHelpText(text: string): TimeItem;
setRequired(enabled: boolean): TimeItem;
setTitle(title: string): TimeItem;
}
/**
* A layout item that displays a video. Items can be accessed or created from a Form.
*
* // Open a form by ID and add three new video items, using a long URL,
* // a short URL, and a video ID.
* var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
* form.addVideoItem()
* .setTitle('Video Title')
* .setHelpText('Video Caption')
* .setVideoUrl('www.youtube.com/watch?v=1234abcdxyz');
*
* form.addVideoItem()
* .setTitle('Video Title')
* .setHelpText('Video Caption')
* .setVideoUrl('youtu.be/1234abcdxyz');
*
* form.addVideoItem()
* .setTitle('Video Title')
* .setHelpText('Video Caption')
* .setVideoUrl('1234abcdxyz');
*/
export interface VideoItem {
duplicate(): VideoItem;
getAlignment(): Alignment;
getHelpText(): string;
getId(): Integer;
getIndex(): Integer;
getTitle(): string;
getType(): ItemType;
getWidth(): Integer;
setAlignment(alignment: Alignment): VideoItem;
setHelpText(text: string): VideoItem;
setTitle(title: string): VideoItem;
setVideoUrl(youtubeUrl: string): VideoItem;
setWidth(width: Integer): VideoItem;
}
}
}
declare var FormApp: GoogleAppsScript.Forms.FormApp;