title: Google script to get averaged scores and emails from Google Forms (as Quiz)
body: <p>I need a Google script (GAS) to retrieve both emails and total scores from a Google Form that was turned into a quiz.</p>
  
  <p>Within GAS you can get the score for each question, but I need to get the score of all questions and then average out the final score (each quiz has 20 questions). I also need the email of each person who finished the quiz. These quizzes are done within institutions so the "Collect email addresses" is selected. </p>
  
  <p>I need this and NOT the "responses spreadsheet" because I will be making hundreds of quizzes and I need to put all the grades in one spreadsheet, as a summary.  I do not want to have hundreds of response spreadsheets.</p>
  
  <p>What I have up to now is below, but I cannot seem to get the average score of each quiz and put it beside the email in a spreadsheet. Any help would be appreciated. </p>
  
  <pre><code>function getPoints() {
  var form = FormApp.openById('ID');
   var formResponses = form.getResponses();
   var formItems = form.getItems();
  
   for (var i = 0; i &lt; formResponses.length; i++) {
    var formResponse = formResponses[i];
     var email = formResponse.getRespondentEmail();
  
  /* I need to get all emails from those who responded, 
     not just one and put them in column A.*/
  
     var s = SpreadsheetApp.openById("ID").getSheetByName("Sheet1");
     var sr = s.getRange("A:A").setValues(email);
   }
  
   for (var j = 0; j &lt; formItems.length; j++) { 
     var item = formItems[i];
      if (item.getType() === item.getType().TEXT){
      var points = item.asTextItem().getPoints(); 
      var itemResponse = formResponse.getGradableResponseForItem(item);
      var answer = itemResponse.getResponse();
      var sc = itemResponse.getScore();
  
      /* I need to get all the scores, not just one, and then average
         them, and them put them in column B, beside the corresponding
         email in column A. */
  
      var s = SpreadsheetApp.openById("ID").getSheetByName("Sheet1");
      var sr = s.getRange("B:B").setValues(sc);
      }
   }
  }
  </code></pre>