是否可以将问题和多项选择选项从Google表单导出到Google表格? [英] Is it possible to export questions and multiple choice options from a Google Form to a Google Sheet?
问题描述
我们有一系列Google表单,其中包含多项选择题,每个问题都有4个可能的答案.
We have a series of Google Forms that contain multiple choice questions, each with 4 possible answers.
我希望能够将该问题和所有可能的答案导出到该Google表单中的所有问题和答案.
I would like to be able to export the question and all possible answers to a Google Sheet for all of the questions and answers in that Google Form.
例如:
Q1:英格兰的首都是什么?
Q1: What is the capital of England?
- A:伦敦
- B:巴黎
- C:马德里
- D:赫尔辛基
我尝试了各种附加组件.有允许Google表格> Google表单的加载,但是没有反向加载(我可以找到),因此我认为它将是某种脚本.
I've tried a variety of add-ons. There are loads that allow Google Sheets > Google Form, but nothing in reverse (that I can find), so I assume it will be a script of some kind.
任何帮助将不胜感激.
谢谢.利亚姆.
推荐答案
在下面的代码(我使用Apps脚本制作的代码)中,您可以找到一种方法来从Google表单中提取问题和答案,然后将值放在您选择的某些表
In the following code, which I made using Apps Script, you can find a way to extract questions and answers from a google form and then put the values in a certain sheet of your choice
// Open a form by ID.
var form = FormApp.openById('YOUR-FORM-ID');
// Open a sheet by ID.
var sheet = SpreadsheetApp.openById('YOUR-SHEET-ID').getSheets()[0];
// variables for putting the questions and answers in the right position
var question_position = 0;
var answers_position = 0;
// main function to run
function getFormValues() {
form.getItems().forEach(callback);
}
// Iterate over all questions
function callback(el){
// check if the question is multiple choice
if (el.getType() == FormApp.ItemType.MULTIPLE_CHOICE) {
// change the type from Item to MultipleChoiceItem
var question = el.asMultipleChoiceItem();
var choices = question.getChoices();
// set the title of the question in the cell
sheet.getRange(question_position +1, 1).setValue(question.getTitle());
var i = 0;
// set the answers in the right cells
for (i; i < choices.length; i++){
sheet.getRange(answers_position + 1, 2).setValue(choices[i].getValue());
answers_position++;
}
question_position += i;
answers_position++;
}
question_position++;
}
文档:
如果您想知道我在哪里得到所有这些信息,可以查看以下两个链接:
Docs:
If you're wondering where I got all this info you can check these two links:
- Spreadsheet
- Google Forms
这篇关于是否可以将问题和多项选择选项从Google表单导出到Google表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!