-
Notifications
You must be signed in to change notification settings - Fork 0
/
runsample.js
95 lines (88 loc) · 2.25 KB
/
runsample.js
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
'use strict'
const parseRequest = require('./parseRequest')
const path = require('path')
const google = require('@googleapis/forms')
const { authenticate } = require('@google-cloud/local-auth')
async function runSample(questions) {
const authClient = await authenticate({
keyfilePath: path.join(__dirname, 'credentials.json'),
scopes: 'https://www.googleapis.com/auth/drive',
})
const forms = google.forms({
version: 'v1',
auth: authClient,
})
const newForm = {
info: {
title: 'Creating a new form in Node with aws tes',
},
}
const request = parseRequest(questions)
const NEW_QUESTION = {
requests: request,
}
// const NEW_QUESTION = {
// requests: [
// {
// createItem: {
// item: {
// title:
// 'In what year did the United States land a mission on the moon?',
// questionItem: {
// question: {
// required: true,
// grading: {
// pointValue: 2,
// correctAnswers: {
// answers: [{ value: '1965' }],
// },
// },
// choiceQuestion: {
// type: 'RADIO',
// options: [
// { value: '1965' },
// { value: '1967' },
// { value: '1969' },
// { value: '1971' },
// ],
// shuffle: true,
// },
// },
// },
// },
// location: {
// index: 0,
// },
// },
// },
// ],
// }
const updateSettings = {
requests: [
{
updateSettings: {
settings: {
quizSettings: {
isQuiz: true,
},
},
updateMask: '*',
},
},
],
}
const res = await forms.forms.create({
requestBody: newForm,
})
const up = await forms.forms.batchUpdate({
formId: res.data.formId,
requestBody: updateSettings,
})
const result = await forms.forms.batchUpdate({
formId: res.data.formId,
requestBody: NEW_QUESTION,
})
console.log(result.data)
return res.data
}
module.exports = runSample