L N*_*col 6 google-sheets google-apps-script google-forms
我们有一系列包含多项选择题的 Google 表单,每个问题都有 4 个可能的答案。
对于该 Google 表单中的所有问题和答案,我希望能够将问题和所有可能的答案导出到 Google 表格。
例如:
Q1:英国的首都是哪里?
我尝试了各种附加组件。有一些负载允许谷歌表格>谷歌表单,但没有反向(我能找到),所以我认为它将是某种脚本。
任何帮助将非常感激。
谢谢。利亚姆。
在我使用 Apps Script 编写的以下代码中,您可以找到一种从 Google 表单中提取问题和答案的方法,然后将这些值放入您选择的某个工作表中
// 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++;
}
Run Code Online (Sandbox Code Playgroud)
如果您想知道我从哪里获得所有这些信息,您可以查看以下两个链接:
这似乎您需要一个 Apps 脚本插件或手动开发的 Apps-Script 脚本。尝试找一个自由职业者或同事来为你构建它。
表格是最容易使用的: https ://developers.google.com/apps-script/reference/spreadsheet/
归档时间: |
|
查看次数: |
12814 次 |
最近记录: |