How to check if a response is correct?

2019-07-16 04:00发布

问题:

I want to create a tailor-made feedback sheet for my pupils depending on their answers to questions on a Google Form.

When iterating through ItemResponses from a Form response using the following code:

function response_deal() {
      var form = FormApp.openById('bla');
     var formResponses = form.getResponses();
     for (var i = 0; i < formResponses.length; i++) {
     var formResponse = formResponses[i];
     var itemResponses = formResponse.getItemResponses();
     for (var j = 0; j < itemResponses.length; j++) {
     var itemResponse = itemResponses[j];
     Logger.log('Response #%s to the question "%s" was "%s" and the score was "%s"',
     (i + 1).toString(),
     itemResponse.getItem().getTitle(),
     itemResponse.getResponse(),
     itemResponse.getScore()  );
     }
     }

     }

I need some code that will check whether the itemResponse is correct e.g.

if itemResponse.isCorrect()

or similar.

Does anyone know of there is a suitable method for this?

One technique I tried is to use the:

 itemResponse.getScore()

method but this returns null even if I setScore(1) etc. unless I allow the assignment to be graded and release a points score, which I don't want to do.