2017-01-30 55 views
0

因此,我对Google脚本编程颇为陌生,但我目前正在使用它来创建表单。它使用自动为表单中涉及的每个人生成的QuestionGrid。对4个问题中的每一个都有可能的3个回答。每个问题的选项都是-1,0或1.我想要一种方法来限制任何成员对每个人的特定问题的回应数量。我的想法是,我有一些方法来检查他们给出的回答,并在两个变量中跟踪-1和1的数量。如果一个变量超出了我设置的数量,则会引发错误。在QuestionGrid中限制Google表单响应

这是我能解释我的问题所能做的最好的,但为了更清晰地提供帮助,我包含了一个代码片段和问题网格格式的图片。如果还有什么不清楚的地方,请告诉我。

感谢您给予的任何帮助!

代码段:

function makeEvals(){ 
    var form = FormApp.create('Winter 2016 Evals'); 
    form.collectsEmail(); 
    form.setCollectEmail(true); 
    var names = ['Person1','Person2','Person3','Person4']; 
    for(var i = 0; i<names.length; i++){ 
    var questionGrid = form.addGridItem(); 
    questionGrid.setTitle(names[i]); 
    questionGrid.setRows(['This person is actively engaged with floor','This person actively contributes time and energy to benefit House', 
          'This person reflects floor in a professional manner','This person is an overall good member of floor']); 
    questionGrid.setColumns(['-1 (Does not meet expectations)','0 (Meets expectations)','1 (Exceeds expectations)']); 
    questionGrid.setRequired(true); 

Image of question grid

回答

0

您可以使用此tutorial指其中功能会检查响应的数量,如果超过您设置的限制,你可以修改它抛出一个alert dialog。您可以使用responses.length来检查您要设置的响应的限制。希望这可以帮助!