How to Get Score for Grid Item in Forms

315 views
Skip to first unread message

Amit Agarwal

unread,
Feb 29, 2020, 8:30:52 AM2/29/20
to Google Apps Script Community

Would anyone know if it is possible to retrieve the score of Grid questions with Apps Script

Screenshot 2020-02-29 at 6.54.14 PM.png
Screenshot 2020-02-29 at 6.58.20 PM.png

David Tew

unread,
Feb 29, 2020, 8:45:30 AM2/29/20
to google-apps-sc...@googlegroups.com
Amit, this is something in one of my scripts ... but I don't have much familiarity with it, so might not be what you're looking for.  (NOTE: function includes cases for some other response types which you haven't asked for)

function responseToText(itemResponse) {
  switch (itemResponse.getItem().getType()) {
    case FormApp.ItemType.CHECKBOX:
      return itemResponse.getResponse().join("\n");
      break;
    case FormApp.ItemType.GRID:
      const gridResponses = itemResponse.getResponse();
      return itemResponse.getItem().asGridItem().getRows().map(function(rowName, index) {
//        Logger.log(rowName);
        return rowName + ": " + gridResponses[index];
      }).join("\n");
      break;
    case FormApp.ItemType.CHECKBOX_GRID:
      const checkboxGridResponses = itemResponse.getResponse()
      return itemResponse.getItem().asCheckboxGridItem().getRows().map(function(rowName, index) {
//        Logger.log(rowName);
        return rowName + ": " + checkboxGridResponses[index];
      }).join("\n");
      break;
    default:
      return itemResponse.getResponse();
  }
}

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/8868b018-49a2-414e-84d0-9669f00ad48a%40googlegroups.com.


--
Regards
David Tew


Amit Agarwal

unread,
Feb 29, 2020, 9:36:49 AM2/29/20
to google-apps-sc...@googlegroups.com
Thanks David.

I am actually trying to extract the score for grid-style questions and have not been successful so far.



Reply all
Reply to author
Forward
0 new messages