简体   繁体   中英

Share individual docs google drive

I am a teacher and I am starting using google classroom. Since a few weeks I scan the assignments of my students, I correct the exam papers and I get a pdf and also a video of the correction for each of my students. With python I was able to collect and organize all these steps quite easily. Now I get on a google drive all the files named with the name of my students. I want to share It with them individually. I read a lot on Internet to find a solution but It seems that nobody has done this before. There is already some thing which looks like what I want but I can't use It for my purpose (AutoCrat). I am sure that I can do a google sheet with the file adresses of each document, the email of each of my students and run a script to share the documents with the right student. I have some basics with python but I do not know google script. Could someone help me to get what I want ? Thanks, Benoît.

I have made some progress.
Finally I wrote a script with python to give the right name to the files.
Then I put the files in a folder named "dm3_1ereS" and I wrote a script linked to a google sheet that contains some information about the students. Below The script I wrote.
The active sheet has several columns.
The first one contains an information to know if the student was there ("") or not "abs"), the second one his name, the third one is his surname and the last one his email. In the first cell next to the row of the last student I put the string "fin" to be sure that the while loop will stop.
getFolderID(dossier) returns the id of dossier.
The idea of the script is while I don't check for all students, I check if he did the assignment. In that case, I look to his file in "dm3_1ereS" with his name, I share it with him and send him a notification. Then I take the next student to do the same thing.

function partage_notification() {
  var dossier = "dm3_1ereS"; 
  var dossier_id = getFolderID(dossier); 
  var app = SpreadsheetApp ;
  var classeur = app.getActiveSpreadsheet();
  var feuille = app.getActiveSheet();
  var row = 2;
  var col = 1;
  var folder = DriveApp.getFolderById(dossier_id); 
  var cellule = feuille.getRange(row,col).getValue(); 
  while (cellule != "fin") { 
    if (cellule == "") { 
      var nom = feuille.getRange(row,col+1).getValue();
      var copie = folder.searchFiles("title contains '" + nom + "'").next(); 
      var mel = feuille.getRange(row,col+3).getValue(); 
      copie.addViewer(mel); 
    }
    var row = row + 1; 
    var cellule = feuille.getRange(row,col).getValue();
  }
}

I do not understand why but it seems that my script doesn't give always the same result. I did a lot of trials and I can't fix it.
Could you please have a look and help me. Regards, Benoît. PS : I hope my english won't be a problem to understand me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM