[ARCHIVED] JSON Structure of rubric_assessment - properties vs array

frank_boukamp
Community Member

I have a question about the schema of the JSON for a rubric assessment.

Specifically, I am working with a GET query that aims to retrieve the marking comments and scores from a rubric:

GET /api/v1/courses/:course_id/assignments/:assignment_id/submissions/:submission_id?include[]=rubric_assessment

I am working in Microsoft PowerApps and using Microsoft Flows to retrieve the JSON data from Canvas and pass it on to a PowerApp. The challenge I need to overcome is related to the schema, as MS Flows requires me to define a schema for my "RetrieveSubmissionDetails" Flow.
I first used the data I get from Canvas to automatically generate a schema. But that schema only works for submissions in this specific assignment, as the IDs of the rubric items are used within the schema:

        "rubric_assessment": {
            "type": "object",
            "properties": {
                "_8534": {
                    "type": "object",
                    "properties": {
                        "rating_id": {
                            "type": "string"
                        },
                        "comments": {
                            "type": "string"
                        },
                        "points": {
                            "type": "integer"
                        }
                    }
                },
                "_7209": {
                    "type": "object",
                    "properties": {
                        "rating_id": {},
                        "comments": {
                            "type": "string"
                        },
                        "points": {
                            "type": "integer"
                        }
                    }
                },
                "_4553": {
                    "type": "object",
                    "properties": {
                        "rating_id": {},
                        "comments": {
                            "type": "string"
                        },
                        "points": {
                            "type": "number"
                        }
                    }
                }
            }
        }

 

The issue with this schema is that each rubric_assessment property has a unique identifier (e.g. "_8534"). So, this schema only works for a set of rubrics already known. However, I need the function to be able to retrieve rubric_assessment details that will be generated in the future; so their unique identifiers are not known yet.

I am wondering why the JSON data for a rubric_assessment isn't returned as an array, rather than a set of unique properties. It seems what I need is a structure that fits the following schema:

        "rubric_assessment": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                    	"type": "string"
                    },
                    "comments": {
                        "type": "string"
                    },
                    "points": {
                        "type": "integer"
                    },
                    "rating_id": {
                        "type": "string"
                    }
                }
            }
        }

Is there a way to retrieve comments and points from a rubric as an array, rather than as a set of unique properties?
I am currently developing a work-around that takes the original JSON and rewrites it into a format that fits the second schema before it gets passed on to my PowerApp - but that seems unnecessarily complicated.

Any help is appreciated!
Thanks!

Labels (2)
0 Likes