我一直在努力获取正确的代码来设置Google Form Multi Choice Grid中的Column Choices。我的代码不断给我调试错误
TypeError:在对象Item中找不到函数setColumns。 (第26行,“人口危险选择”文件。)
我尝试过setColumnChoices和setColumns,但结果似乎相同。
function PopulateHazardChoices(){
// call the form and connect to the Question Item
var form = FormApp.openById("FakeFormID");
var QuestionItem = form.getItemById("fakeItemID");
// identify the sheet Hazard Choices needed to populate the question selections
var ss = SpreadsheetApp.getActive();
var DataFactors = ss.getSheetByName("DataFactors");
// grab the Hazards in the first column of the sheet from the Group of Hazard Choices
// use sheet Row Number for First Hazard in the group of choices; use 1 as the index column A; number of rows included in range
// 7,1,3 would be Row 7, Column A, 4 rows in the range - therefore A7 through A10
// [Conditions of Runway] Hazard Group
var HazardValues = DataFactors.getRange(7,1,4);
var HazardSelections = [];
// convert the array ignoring empty cells
for(var i = 0; i < HazardValues.length; i++)
if(HazardValues[i][0] != "")
HazardSelections[i] = HazardSelections[i][0];
// populate the Wind Question with the array data
QuestionItem.setColumns(HazardSelections);
}
计划是从名为“ DataFactors”的工作表中填充网格列,以便对危险列表进行的任何更改都将在表单上完全相同。当用户提交表单时,将选择内容与表单进行比较,并分配一个点值。希望这将解决表格提交与危险值之间的比较不正确的问题。 使用下拉列表获得了不错的结果,但似乎无法使该方法适用于“多选网格”。
答案 0 :(得分:0)
以下示例适用于新商品
// 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']);
如果该项目已经存在,那么一旦获得该项目,并且在使用setColumns
之前,应使用接口项目的asGridItem。
var gridItem = QuestionItem.asGridItem();
gridItem.setColumns(HazardSelections);
答案 1 :(得分:0)
Ruben,谢谢您的帮助。这是带有几种不同类型的表单项(网格,CheckboxGrid和MultipleChoice)的完成的脚本。 谢谢, 杰克
function PopulateHazardChoices(){
// call the sheet and form needed to populate the question selections
var ss = SpreadsheetApp.getActive();
var DataFactors = ss.getSheetByName("RiskValues");
var form = FormApp.openById("FakeFormID");
// For each Group of Hazard Choices - repeat the folowing
// identify the Hazards in Column A of the sheet for each Group of Hazard Choices
// Use Row Number for First Hazard in the Group of Harard Choices
// Use 1 as the index Column A
// Number of rows included in the Group
// 2,1,3 would be Row 2, Column A, 3 rows in the range - therfore A2 through A4
//declare QuestionItem including type of item i.e. .asGridItem();
// populate the Question with the array data
// Crew Compliment - Hazard Group A3 through A5
var HazardValues = DataFactors.getRange(3,1,3).getValues();
var QuestionItem = form.getItemById("FakeItemID").asGridItem();
QuestionItem.setColumns(HazardValues);
//End of Hazard Group
// pAve Rotorcraft - Hazard Group A40 through A43
var HazardValues = DataFactors.getRange(40,1,4).getValues();
var QuestionItem = form.getItemById("FakeItemID").asCheckboxGridItem();
QuestionItem.setColumns(HazardValues);
//End of Hazard Group
// paVe Runway Length - Hazard Group A72 through A75
var HazardValues = DataFactors.getRange(72,1,4).getValues();
var QuestionItem = form.getItemById("FakeItemID").asMultipleChoiceItem();
QuestionItem.setChoiceValues(HazardValues);
//End of Hazard Group
} //End function PopulateHazardChoices
// Edit Journal - Created December 2019, Jack Gainer, TSTC Chief Pilot
// Initial Implentation Tests - January 2019
// Add remaiining Hazard Group setValues code - February 2019
答案 2 :(得分:0)
这可以令人满意地将Google表格中的列和行插入到Google Forms多项选择网格项中:
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(RNN, self).__init__()
希望有帮助。