Query Forms API to get scores or results from form submission

Copper Contributor

Hello All,

May be one for the Forms/Dev Community but thought I would try here. We have a process where 4 forms are submitted weekly (Every week has 4 new forms). We currently gather responses into a SPO list and feed that in PowerBI.

A new requirement has come in that the forms (which are quizzes) also need to push the scores to SPO. We have done this with conditionals to check the text of the correct answers but the workload for this is unmanageable. I know there is a forms Api (undocumented) and we have successfully queried it to get the quiz questions, but these doesn't seem to be any info in there about the right answer. 

My question is, is it possible to query the forms API to get the response points, either total or per question?

Included is the starting point, just need to know if anyone knows the URI to get what we need.

6 Replies

@jshaunBTC 

 

Use below API to get the form definition which contains the answer and points information per question -

GET https://forms.office.com/formapi/api/{TenantId}/users/{UserId}/light/forms('FormId')?$select=id,order,otherInfo,questions($expand=choices)

 

e.g.,

"questionInfo": "{\"Choices\":[{\"Description\":\"Option 1\",\"IsGenerated\":true,\"IsAnswerKey\":true},{\"Description\":\"Option 2\",\"IsGenerated\":true,\"IsAnswerKey\":false}],\"ChoiceType\":1,\"AllowOtherAnswer\":false,\"OptionDisplayStyle\":\"ListAll\",\"ChoiceRestrictionType\":\"None\",\"ShowRatingLabel\":false,\"Point\":10}",

 

Use below API to get the aggregated results which contains responses and total score -

GET https://forms.office.com/formapi/api/{TenantId}/users/{UserId}/forms('FormId')/GetAggregateQuizData

 

e.g.,

"quizSummaryData": {
"averageScore": 10.0,
"averageSubmitTimeSeconds": 2.0,
"count": 1

Will this work for grabbing the score results when a person submits are response, or will only ever give aggregate results for everyone?
It will aggregate results for everyone, but you can filter by user name (email address) since the results contain that identifying information.
Great thanks, Dingkun Xie, I'll let you know when Ive gone back to it and will mark you as bets response.
Using GetAggregateQuizData uri returns the following failure:

Unexpected response from the service
clientRequestId: 2c821506-a025-4e00-a49e-0ffdeb75bda4

Can I confirm, is the userID in the query params the owner of said form?

@jshaunBTC

 

It depends on the type of form/quiz you created. If it's a personal form, the form owner's user object ID (GUID) will be used, whereas if it's a group form, the group ID will be used. You can obtain the tenant ID and user ID through the network trace when you load the form. For example, in Edge developer mode, open the form and view the network trace sent to forms.office.com. The URLs of the APIs sent to the server will contain the tenant ID and user (group) ID of your form.