mrnavaone

5

May 7th, 2020
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function CalculoNotas() {
  2.    
  3.   var sps = SpreadsheetApp.openByUrl
  4.   ('https://docs.google.com/spreadsheets/d/1Yn-z7X-mb9TWaxjWWps79qb_v68h9KHFAWDMn7jLfU0/edit#gid=0')
  5.   //Editamos el documento
  6.   var sheet =  sps.getSheets();
  7.   var data =  sheet[0].getDataRange().getValues();
  8.  
  9.     for (i in data)
  10.   {
  11.     var row = data[i];
  12.     var Nota1 = row[1];
  13.     var Nota2 = row[2];
  14.     var Nota3 = row[3];
  15.     var Total = (Nota1 * 0.30 ) + (Nota2 * 0.30) + (Nota3 * 0.40);
  16.    
  17.    if (Total >= 6 )
  18.     {
  19.    
  20.      var StarRow = 1 + +i;
  21.      sheet[0].getRange(StarRow, 6).setValue("Aprobado");
  22.      }
  23.       else
  24.       {
  25.      
  26.      var StarRow = 1 + +i;
  27.      sheet[0].getRange(StarRow, 6).setValue("Reprobado");
  28.       }
  29.    
  30.     var StarRow = 1 + +i;
  31.     sheet[0].getRange(StarRow, 5).setValue(Total);
  32.   }
  33.  
  34. }
RAW Paste Data