从电子表格更新Google表单的脚​​本 [英] Script to update Google Form from Spreadsheet

查看:128
本文介绍了从电子表格更新Google表单的脚​​本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题:

我似乎无法将这些信息拼凑在一起,即使看起来很简单,也无法在任何地方找到它。当我找到帮助时,他们只是告诉我手动输入(但我的用户不能被信任),或者创建一个新表单(而不是一个选项)。



什么我需要的是能够保持:


  • 相同的Google表单

  • 它的ID和链接到相同的电子表格

  • 相同的20个段落文本问题(标题保持不变)



  • 不能有任何新问题或任何会改变电子表格中响应目标页面的名称或布局。



    然而,我想要的是:


    • 可以从电子表格中的20个单元格更新这些问题下方的帮助文本 。如果我的单元格来自同一电子表格中名为questions!b2:b19的范围,那么如何使用脚本来获取其内容并在Google表单上更新这些段落问题中的帮助文本?



    任何帮助都将不胜感激。

    解决方案

    在AppScript中创建您的表单可能最为容易。在创建表单后,您可以使用AppScript访问您的电子表格。阅读工作表中的信息,并使用它在 setHelpText



    以下是一个基本示例。

      var form = FormApp.create('New Form'); 
    var item = form.addCheckboxItem();
    var ss = SpreadsheetApp.openById(< ID>);
    var val = ss.getRange(< RANGE>)。getValue();

    item.setTitle('Question');
    item.setHelpText(val);
    item.setChoices([
    item.createChoice('ONE'),
    item.createChoice('TWO'),
    item.createChoice('THREE')
    ]);


    Here's my problem:

    I can't seem to piece this info together nor find it anywhere even though it seems simple enough. When I find help, they just tell me to enter it manually (but my users can't be trusted) or make a new form (not an option).

    What I need is to be able to keep:

    • the same google form
    • it's ID and link to the same spreadsheet
    • the same 20 "paragraph text" questions (titles remain the same).

    There can't be any new questions or anything that would change the name or layout of the response destination page in the spreadsheet.

    However, what I want is:

    • to update the help text below these questions from twenty cells in the spreadsheet. If my cells are from a range called questions!b2:b19 in the same spreadsheet, how do I use a script to take their contents and write over and update the help text in these paragraph questions on the google form?

    Any help would be greatly appreciated.

    解决方案

    It might be easiest to create your form in AppScript. With your form created, you can then use AppScript to access your spreadsheet. Read the information from the sheet and use it to create the help text on your questions with setHelpText.

    Here's a basic sample.

    var form = FormApp.create('New Form');
    var item = form.addCheckboxItem();
    var ss = SpreadsheetApp.openById("<ID>");
    var val = ss.getRange(<RANGE>).getValue();
    
    item.setTitle('Question');
    item.setHelpText(val);
    item.setChoices([
            item.createChoice('ONE'),
            item.createChoice('TWO'),
            item.createChoice('THREE')
        ]);
    

    这篇关于从电子表格更新Google表单的脚​​本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆