1

My students all have a Google account, but use different emails (like john@hotmail.com).I tried to write a webapp that would get from my grade spreadsheet the row with the webapp's user's email address, so that each student would only see his or her grades. That webapp uses: Session.getActiveUser().getEmail()

This only works for users in the same domain as the script, I have to run the script as the webapp user (which is ok -- my students trust me that far!). Here is that restriction:

Returns a User object describing the current user. In limited-privilege executions (such as in response to onOpen or onEdit), we only return the identity of the active user if both the user and the script owner are part of the same domain. This is to protect the privacy of consumer users, who may not want their email address exposed.

My script works, but I have to put the table of grades directly in the script and update the webapp each time I update my spreadsheet. Yeck!

I can't share my grade spreadsheet because then they would see each other's grades. So now I am brainstorming other workarounds.

Here is one example:

  1. Share a second spreadsheet, copy the grades from my spreadsheet with an update function that encrypts the grades. The webapp sucks up the data from the shared spreadsheet and decrypts. Now a simple update of a spreadsheet is all that is needed -- the webapp doesn't need to be republished. (There are some simple encryption options, like base64encode with maybe a little scrambling...?)

  2. Find a way to automatically update the webapp and republish. (Don't know how to do that.)

  3. ????

Any suggestions?

PS: if 1 seems feasible, some suggestions for simple encryption code?

4

3 回答 3

2

There are some simple encryption options, like base64encode with maybe a little scrambling...?

Yes, the GAS has functions to encode/decode using the Base64 algorithm - Utilities.base64Encode, Utilities.base64Decode, but I think, it is not an option even with a little scrambling. Students are very clever. My opinion is to use a JavaScript implementation of a encryption algorithm, for instance the Blowfish. There are a number of its implementations on JavaScript (here and here). These implementations should work in the GAS environment without any changes or with small modifications. It is should be sufficient to copy and paste the source code to the GAS Editor.

于 2012-10-16T11:42:33.037 回答
1

我不明白您为什么说“我的脚本有效,但我必须将成绩表直接放在脚本中,并在每次更新电子表格时更新 web 应用程序”

例如,使用 flextable 创建一个显示电子表格一部分的 web 应用程序非常容易。该应用程序的每个实例都会自动包含与用户相关的内容,您只需更新主电子表格即可获得所需内容。我不知道你为什么要为此编码数据......我认为通过谷歌登录的用户识别应该足够了,不是吗? 这是此类 web 应用程序的示例,您看到的数字取自主电子表格中的特定列(对于此公共副本,我将应用程序设置为以“我”身份运行以避免授权过程,但实际上每个用户都被识别并且只看到他的数据)。

电子表格本身和代码可在此处查看,如果您需要更多信息,请随时返回。

于 2012-10-16T08:44:15.643 回答
0

是否可以将工作表与 scriptDB 同步?然后查询user=loginID所在的数据库

于 2012-10-16T17:23:52.847 回答