google-apps-scriptgoogle-sheetsgoogle-form-quiz

Get a Complete Score from Spreadsheet


I have a spreadsheet collecting from multiple quizzes. Each varies in length and points available. I am using onFormSubmit trigger in my spreadsheet to copy relevant info (name, email, score) of the most recent submission over to another sheet for the next step of the workflow.

var score = inSheet.getRange(inRow, colNoScore).getValue();

This returns the value of "5", and not "5/10" as it is displayed in the spreadsheet.

How do I access not only the value of correct responses, but also the possible total so that I can create an average?


Solution

  • Instead of getValue() use getDisplayValue()

    Reference

    https://developers.google.com/apps-script/reference/spreadsheet/range#getdisplayvalue