如果用户在考试中途断开连接,如何自动提交 google 表单?

how to auto submit google form if user disconnected in the middle of exam?

如果用户在考试中途断开连接,我对如何提交 Google 表格进行了大量研究。它不是基于时间我想要的。

Google 表格不保存答案。最近 Google 在 Google Workspace for Education 介绍了它,它可以在用户断开连接时保存答案。但我正在寻找普通的 Gmail 用户。

What I am trying to do is, I will enable Edit After Submit option. So when a user get out of the Form page due to electricity or internet issue, the Form will be automatically submitted and then s/he will get an email with a link to edit. Their previous response will be saved. Now after the duration of the exam I will stop taking responses. How could I achieve it?

与 Google 表单交互的唯一方法是 submit

所以基本上你无法节省 disconnect

您可能想要使用您提到的 Edit after submit

普通 Gmail 用户可以使用。你能具体说说你的问题是什么吗?


如果您需要在用户断开连接时自动提交。那么你需要一个 web app and submit with beforeunload

Google Apps 脚本

function handleSubmit(formData) {
  const id = 'formId';
  const form = FormApp.openById(id);
  const items = form.getItems();
  const response = form.createResponse();
  Object.keys(formData).forEach(function(key) {
    const i = items[key].asTextItem();
    const r = i.createResponse(formData[key]);
    response.withItemResponse(r);
  });
  response.submit();
  // return response.getEditResponseUrl();
}

网络应用程序

  window.onbeforeunload = function(e) {
    e.preventDefault();
    const formData = new FormData(form);
    google.script.run.handleSubmit(formData);
    return 'Form submitted';
  }