Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 将特定字符串与google工作表中的数字关联_Google Sheets_Spreadsheet - Fatal编程技术网

Google sheets 将特定字符串与google工作表中的数字关联

Google sheets 将特定字符串与google工作表中的数字关联,google-sheets,spreadsheet,Google Sheets,Spreadsheet,我正在使用谷歌表单收集回复,然后用它给人们打分。不幸的是,其中一些响应仅在非数字形式下才有意义,以下是一个示例: 问:你最常用的交通方式是什么 汽车 拼车 公共交通 自行车 走 我想让google sheets自动将这些字符串响应转换成数字,比如Car将是20,carpool 15等等,这样我就可以对它们进行“评分”并给它们打分。这可以通过谷歌表单完成吗?或者是某种字典功能 谢谢大家! 是的,这可以通过谷歌表单完成。看看 使用他们的代码,你可以 var formResponses = For

我正在使用谷歌表单收集回复,然后用它给人们打分。不幸的是,其中一些响应仅在非数字形式下才有意义,以下是一个示例:

问:你最常用的交通方式是什么

  • 汽车
  • 拼车
  • 公共交通
  • 自行车
我想让google sheets自动将这些字符串响应转换成数字,比如Car将是20,carpool 15等等,这样我就可以对它们进行“评分”并给它们打分。这可以通过谷歌表单完成吗?或者是某种字典功能


谢谢大家!

是的,这可以通过谷歌表单完成。看看

使用他们的代码,你可以

var formResponses = FormApp.getActiveForm().getResponses();
// Go through each form response
for (var i = 0; i < formResponses.length; i++) {
  var response = formResponses[i];
  var items = FormApp.getActiveForm().getItems();
  // Assume it's the first item
  var item = items[0];
  var itemResponse = response.getGradableResponseForItem(item);
  if (itemResponse != null && itemResponse.getResponse() == 'Car') {
   var points = item.asMultipleChoiceItem().getPoints();
   itemResponse.setScore(points * 20);
   // This saves the grade, but does not submit to Forms yet.
   response.withItemGrade(itemResponse);
   }
}
// Grades are actually submitted to Forms here.
FormApp.getActiveForm().submitGrades(formResponses);
var formResponses=FormApp.getActiveForm().getResponses();
//检查每一个表单响应
对于(var i=0;i
是的,这可以通过谷歌表单完成。看看

使用他们的代码,你可以

var formResponses = FormApp.getActiveForm().getResponses();
// Go through each form response
for (var i = 0; i < formResponses.length; i++) {
  var response = formResponses[i];
  var items = FormApp.getActiveForm().getItems();
  // Assume it's the first item
  var item = items[0];
  var itemResponse = response.getGradableResponseForItem(item);
  if (itemResponse != null && itemResponse.getResponse() == 'Car') {
   var points = item.asMultipleChoiceItem().getPoints();
   itemResponse.setScore(points * 20);
   // This saves the grade, but does not submit to Forms yet.
   response.withItemGrade(itemResponse);
   }
}
// Grades are actually submitted to Forms here.
FormApp.getActiveForm().submitGrades(formResponses);
var formResponses=FormApp.getActiveForm().getResponses();
//检查每一个表单响应
对于(var i=0;i
另一种不需要编码的方法是制作带有选项编码的工作表,然后使用VLOOKUP进行翻译。

另一种不需要编码的方法是制作带有选项编码的工作表,然后使用VLOOKUP进行翻译。

您好,谢谢您的回复!你会碰巧有这方面的示例代码吗?如果没有示例电子表格,很难提供示例代码,但一般来说:首先用字典制作另一张表,比如Sheet2,在A列中列出你的选项(汽车、拼车、公共交通、自行车、步行),在B列中列出它们的值(15、20等)。然后使用=VLOOKUP(,Sheet2!A:B,2,FALSE)将选项转换为它们的值。您好,感谢您的回复!您是否碰巧有用于此的示例代码?如果没有示例电子表格,很难提供示例代码,但通常情况下:首先使用字典制作另一张表,比如Sheet2,使用您的选项(汽车、拼车、公共交通、自行车、步行)和B列中的值(15、20等)。然后使用=VLOOKUP(,Sheet2!A:B,2,FALSE)将选项转换为它们的值。您好,谢谢您的快速回复!我必须在本周末后尝试此选项,但这似乎是我想要的。您好,谢谢您的快速回复!我必须在本周末后尝试此选项,但这似乎是我想要的