cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
frank_boukamp
Community Member

JSON Structure of rubric_assessment - properties vs array

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!

0 Kudos
1 Reply
frank_boukamp
Community Member

Well, having received no reply, I wonder whether I am posting in the wrong forum.

Let me be clearer about what I mentioned in the post above: I think the JSON Structure provided by Canvas is flawed and should be fixed. The ID should not be the name of the object, but instead be represented as an attribute. 
The current JSON structure makes it impossible to use Canvas JSON data in PowerApps and PowerAutomate. A lot of post-processing of the JSON data is needed to turn it into a proper structure for which a schema can be defined. This post-processing is very costly and currently prevents us from leveraging the CANVAS API in our PowerApp/PowerAutomate project.

Tags (2)