2

I am an instructor. I share a template_spreadsheet with students. I want a function that will copy the template_spreadsheet to the student's local drive as student_spreadsheet and then have the function edit the student_spreadsheet. I don't know how I would do that.

I have looked at this code: How to copy google drive folder into another google drive account by using App Script? and it is similar to my problem, but that code still doesn't show how to do that without knowing the target folder (I need to figure out how to get access to the student's drive).

function createCopy(){
  var template_spreadsheet = SpreadsheetApp.openById(template_spreadsheet_id);
  var student_spreadsheet = template_spreadsheet_id.copy(template_spreadsheet.getName()); 
  return student_spreadsheet;
}

This obviously just copies the template to my own Google Drive. I want it to copy to the students' Google Drive that I have shared it with.

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • You cannot write/create a new file in someone else's drive but per your use-case, have you considered making them (students) the owner of the sheet? Let me know if that's feasible so we could help script it accordingly. – Sourabh Choraria Dec 25 '19 at 07:31

1 Answers1

0

To access a "a different drive" you could use OAuth but first you should someway make that the other user authorize your script to do that or if you are using G Suite account you should ask the G Suite domain admin to enable domain-wide delegation of authority.

Rubén
  • 34,714
  • 9
  • 70
  • 166