My google script which based on Google Sheet and Form


// get sheet data
function getSpreadsheetData(sheetId) {
// This function gives you an array of objects modeling a worksheet's tabular data, where the first items — column headers — become the property names.
var arrayOfArrays = SpreadsheetApp.openById(sheetId).getDataRange().getValues();
var headers = arrayOfArrays.shift();
return arrayOfArrays.map(function(row) {
return row.reduce(function(memo, value, index) {
if (value) {
memo[headers[index]] = value;
}
return memo;
}, {});
});
} // class definition
function instance(appName, url, oldLineNum, newLineNum, importedLibrary, author) {
var o = new Object();
o.appName = appName;
o.url = url;
o.oldLineNum = oldLineNum;
o.newLineNum = newLineNum;
o.importedLibrary = importedLibrary;
o.author = author;
return o;
} function getInstFromRow(row) {
return new instance(row['appName'], row['url'], row['oldLineNum'], row['newLineNum'], row['importedLibrary'], row['author']);
} function main() { var sheetId = '1ixlsO8claL7KMouUe8S8GKhn_yZI6yVh-A8jvbzf71A' var instances = getSpreadsheetData(sheetId);
while (instances.length != 0) {
var curInstanceList = [];
// get head
var curInst = getInstFromRow(instances[0]);
curInstanceList.push(curInst);
var tmpInstances = [];
for (var index = 1; index < instances.length; index++) {
var tmpInst = getInstFromRow(instances[index]);
// if belongs to same author
if (tmpInst.author == curInst.author) {
curInstanceList.push(tmpInst);
} else {
tmpInstances.push(tmpInst);
}
}
instances = tmpInstances
// get all instances with same author
var formName = 'Survey on redundant implementations between Android apps and APIs';
var form = FormApp.create(curInst.author + ' - ' + formName); form.setTitle(formName);
form.setDescription('We are going to show the customized diff patch here ... FromFoutse(you need to have a section describing your study!) and since you found code snippets from their code you may want to show it to them and formulate specific questions to understand their motivations for refactoring,...etc)'); // sect1
var sect1 = form.addSectionHeaderItem();
sect1.setTitle('Example(s):');
var str = '' while (curInstanceList.length != 0) {
// get head
var instTmpHead = curInstanceList[0];
str += ('Patch Url : \n' + instTmpHead.url + '\nOld Line Num :\n' + instTmpHead.oldLineNum + '\nNew Line Num :\n' + instTmpHead.newLineNum + '\nImported Library :\n' + instTmpHead.importedLibrary + '\n');
var tmpCurInstanceList = []
for (var i = 1; i < curInstanceList.length; i++) {
var instTmp = curInstanceList[i];
// if belongs to same url
if (instTmpHead.url == instTmp.url) {
str += ('Old Line Num : \n' + instTmp.oldLineNum + '\nNew Line Num :\n' + instTmp.newLineNum + '\nImported Library :\n' + instTmp.importedLibrary + '\n');
} else {
tmpCurInstanceList.push(instTmp);
}
}
curInstanceList = tmpCurInstanceList;
}
//var item11 = form.addTextItem();
//item11.setTitle(str);
sect1.setHelpText(str) // sect2
form.addPageBreakItem().setTitle('Section 1 of 3');
var sect2 = form.addSectionHeaderItem();
var item21 = form.addMultipleChoiceItem().setTitle('Do you use the API call to refactor your original implementation?')
item21.setChoices([item21.createChoice('Yes'), item21.createChoice('No'), ]).showOtherOption(true);
var item22 = form.addMultipleChoiceItem().setTitle('What is the reason why you did not use the API method in the first place?');
item22.setChoices([item22.createChoice('I did not know about this API method when I was implementing the code.'), item22.createChoice('The required API method had not been introduced at the moment of my implementation.'), ]).showOtherOption(true);
var item23 = form.addMultipleChoiceItem().setTitle('Why did you replace your code with an API call?');
item23.setChoices([item23.createChoice('Because I want to more easily maintain my code.'), item23.createChoice('Because I want to have a higher performance.'), ]).showOtherOption(true);
var item24 = form.addMultipleChoiceItem().setTitle('Do you actively search for API reuse opportunities (i.e., code that can be replaced by API calls)?'); // sect3
var page3 = form.addPageBreakItem().setTitle('Section 2 of 3');
var sect3 = form.addSectionHeaderItem().setTitle('In case you actively search for API reuse opportunities');
var item31 = form.addTextItem();
item31.setTitle('How do you perform such search?'); // sect4
var page4 = form.addPageBreakItem().setTitle('Section 2 of 3');;
var sect4 = form.addSectionHeaderItem().setTitle('In case you do not actively search for API reuse opportunities');
var item41 = form.addTextItem();
item41.setTitle('Why don\'t you search such opportunities?'); var choice1 = item24.createChoice('Yes', page3);
var choice2 = item24.createChoice('No', page4);
item24.setChoices([choice1, choice2]); // sect5
var page5 = form.addPageBreakItem().setTitle('Section 3 of 3');;
var sect5 = form.addSectionHeaderItem();
sect5.setTitle('How difficult to find an appropriate API to replace my code?')
var item51 = form.addMultipleChoiceItem();
item51.setTitle('Do you find it challenging to find API reuse opportunities?')
.setChoices([item51.createChoice('Yes'), item51.createChoice('No'), ]);
var item52 = form.addTextItem()
item52.setTitle('Which criteria do you consider when replacing a piece of your own code with a corresponding API implementation?') page4.setGoToPage(page5);
}
}

处理sheet的数据时,里面还有一些自己的逻辑。懒得改了,大家挑自己有用的用吧。

Sheet失效了请联系我。

https://docs.google.com/spreadsheets/d/1ixlsO8claL7KMouUe8S8GKhn_yZI6yVh-A8jvbzf71A/edit#gid=0

其中,1ixlsO8claL7KMouUe8S8GKhn_yZI6yVh-A8jvbzf71A就是sheetId。

My google script which based on Google Sheet and Form的更多相关文章

  1. An attempt was made to call the method com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder; but it does not exist. Its class, com.google.gson.GsonBuilder, is available from the foll

    SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/G:/sharp/repo ...

  2. Google coding Style Guide : Google 编码风格/代码风格 手册/指南

    1 1 1 https://github.com/google/styleguide Google 编码风格/代码风格 手册/指南 Style guides for Google-originated ...

  3. [转]玩转Google开源C++单元测试框架Google Test系列

    gtest的官方网站是: http://code.google.com/p/googletest/ 从官方的使用文档里,你几乎可以获得你想要的所有东西 http://code.google.com/p ...

  4. 转:玩转Google开源C++单元测试框架Google Test系列

    转自http://www.cnblogs.com/coderzh/archive/2009/04/06/1426755.html 前段时间学习和了解了下Google的开源C++单元测试框架Google ...

  5. 玩转Google开源C++单元测试框架Google Test系列(转载)

    越来越多公司采用敏捷开发,单元和回归测试越来越重要,GTest作为最佳C++单元测试工具越来越多的被使用.转自 http://www.cnblogs.com/coderzh/archive/2009/ ...

  6. 《Google软件测试之道》- Google软件测试介绍

    <Google软件测试之道>- Google软件测试介绍 2015-05-21 目录 1 质量与测试  2 角色  3 组织结构  4 爬.走.跑  5 测试类型  相关链接 与Micro ...

  7. 玩转Google开源C++单元测试框架Google Test系列(gtest)(转)

    转自:http://www.cnblogs.com/coderzh/archive/2009/04/06/1426755.html 前段时间学习和了解了下Google的开源C++单元测试框架Googl ...

  8. Google开源C++单元测试框架Google Test

    1.玩转Google开源C++单元测试框架Google Test系列(gtest)之一 - 初识gtest 2.玩转Google开源C++单元测试框架Google Test系列(gtest)之二 - ...

  9. 玩转Google开源C++单元测试框架Google Test系列(gtest)(总)

    原文地址:http://www.cnblogs.com/coderzh/archive/2009/04/06/1426755.html 前段时间学习和了解了下Google的开源C++单元测试框架Goo ...

随机推荐

  1. 小甲鱼Python视频课后答案(第一讲)---仅记录学习

    1.python是什么语言? Python是一种支持面向对象的解释性高级语言,属于脚本语言的一种. 2.IDLE是什么? IDLE是开发python程序的基本IDE(集成开发环境),具备基本的IDE的 ...

  2. week 10 blog

    一.Iterations : 1.do...while : 创建执行指定语句的循环,直到测试条件评估为false.在执行语句后评估条件,导致指定语句至少执行一次. 例子:在以下示例中,do...而循环 ...

  3. android面试题总结加强再加强版(一)

    在加强版的基础上又再加强的android应用面试题集 有些补充略显臃肿,只为学习 1.activity的生命周期. 方法 描述 可被杀死 下一个 onCreate() 在activity第一次被创建的 ...

  4. ABAP表抛FTP通用程序

    主要功能: 1.支持R3所有表(标准.自建)下传,下传方式为FTP 2.支持输出字段选择及顺序调整 3.支持动态条件,不同的表会有不同的选择条件,根据不同的条件选择需要下传的数据 4.支持单表.多表. ...

  5. 百度brpc 压测工具rpc_press解析

    1. 背景 昨天看到一段brpc中的压测代码rpc_press, 看着不错.整理一下. 发压工具的难点不是发送请求,而是要注意下面的2点: 保证能发出足够的qps,比如上万qps 控制发送合理的qps ...

  6. 使用scp命令在多个Linux系统间进行文件复制

    一,什么是scp scp是linux系统下基于ssh登陆进行安全的远程文件拷贝命令.scp命令可以在linux服务器之间复制文件和目录.scp使用ssh安全协议传输数据,具有和ssh一样的验证机制,从 ...

  7. UVA - 1456 Cellular Network

    题目大意: 手机在蜂窝网络中的定位是一个基本问题.如果蜂窝网络已经得知手机处于c1, c2,-,cn这些区域中的一个.最简单的方法是同一时候在这些区域中寻找手机.但这样做非常浪费带宽. 因为蜂窝网络中 ...

  8. R语言中的回归诊断-- car包

    如何判断我们的线性回归模型是正确的? 1.回归诊断的基本方法opar<-par(no.readOnly=TRUE) fit <- lm(weight ~ height, data = wo ...

  9. Dynamic CRM 2016 的备份/恢复/重新部署

    参考:1.https://community.dynamics.com/crm/b/crmviking/archive/2016/02/03/backup-and-restore-strategies ...

  10. LaTeX网址

    https://www.latex-project.org/   latex官网 http://www.latexstudio.net/   国内知名latex学习中心 https://www.ove ...